如何在Android Java中序列化Firestore TimeStamp? [英] How to serialize Firestore TimeStamp in Android Java?

查看:51
本文介绍了如何在Android Java中序列化Firestore TimeStamp?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将一个类作为Extras传递,并且该类具有TimeStamp作为成员并收到以下错误,如何序列化TimeStamp?

I am passing a Class as Extras and the class has TimeStamp as a member and getting the following error, how to serialize TimeStamp?

错误:

java.io.NotSerializableException: com.google.firebase.Timestamp

推荐答案

构造函数重新创建时间戳需要两个值.或者,您可以利用以下事实:它是可打包.

Timestamp contains just two numbers, seconds and nanoseconds. You can serialize them each separately, then recreate the Timestamp using its constructor that takes both values. Or you can take advantage of the fact that it's Parcelable.

这篇关于如何在Android Java中序列化Firestore TimeStamp?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆