【问题标题】:Get Firebase Timestamp in String format android studio以字符串格式获取 Firebase 时间戳 android studio
【发布时间】:2018-09-09 09:21:17
【问题描述】:

我是 Android Studio 初学者。请问如何通过Firebase in String获取android studio中的时间戳?

我用于更新时间戳的代码如下。

  Map<String, Object> map = new HashMap<>();
  map.put("timestamp", ServerValue.TIMESTAMP);                                  
  queue.child(UserInfo).updateChildren(map);

非常感谢!!

【问题讨论】:

标签: android string firebase timestamp long-integer


【解决方案1】:
You can do it:

public class MyTimeStamp {
    private Object timestamp;

    public MyTimeStamp() {

    }

    public Object getTimestamp() {
        return timestamp;
    }

    public void setTimestamp(Object timestamp) {
        this.timestamp = timestamp;
    }
}
And so:

public static void start(Context context) {
    MyTimeStamp timeStamp = new MyTimeStamp();
    timeStamp.setTimestamp(ServerValue.TIMESTAMP);

    Log.d(TAG, "start: ", timeStamp.getTimestamp().toString());
}

【讨论】:

  • 感谢您的建议。请问如何从 Firebase 获取 String 中的时间戳值?因为它目前处于错误 DatabaseException: Failed to convert type of java.lang.Long to String 谢谢!!
猜你喜欢
  • 1970-01-01
  • 2014-05-28
  • 1970-01-01
  • 1970-01-01
  • 2021-06-23
  • 1970-01-01
  • 1970-01-01
  • 2014-04-17
  • 2017-10-06
相关资源
最近更新 更多