gpt4 book ai didi

java - 无法在子进程中使用 HashMap 作为 TIMESTAMP

转载 作者:行者123 更新时间:2023-12-02 01:44:19 25 4
gpt4 key购买 nike

我正在尝试一个新的时间戳,并希望将其作为子项插入。如何做到这一点?

我读过这篇文章:
Write serverValue.timestamp as child in Firebase ..还是不明白

我尝试将 ServerValue.TIMESTAMP 输入到子项中,但未成功。

这是我的代码:

Object timestamp = ServerValue.TIMESTAMP;
reference.child(String.valueOf(timestamp)).child(uid).child("Status").setValue(cA);

我读过这篇文章:

How to save the current date/time when I add new value to Firebase Realtime Database

我按照里面的代码运行,但不能正常工作-->

enter image description here

我应该做什么?

最佳答案

ServerValue.TIMESTAMP 只能写入值,不能用作数据库中的键。因此,如果您想存储时间戳,则必须将其写入属性的值。如果您想要按时间顺序排列的唯一键,请使用 push() 方法。

如此组合:

reference.push().setValue(ServerValue.TIMESTAMP);

关于java - 无法在子进程中使用 HashMap 作为 TIMESTAMP,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53925095/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com