在Kotlin中存储日期和时间的最佳方法是什么。

huangapple go评论64阅读模式
英文:

Best way of storing Date & Time in Kotlin

问题

我实际上有点迷茫。

我需要存储日期和时间以进行简单的使用,例如存储在数据库中,分段的可回收视图等,但关于如何保存日期和时间有太多选项,而且每篇文章都说其中一种方法优于其他方法。

DateCalendarLocalDateTimeInstant 等。

我的问题是,目前最佳的存储日期和时间的方式是什么?

英文:

I'm honestly kinda lost.

I need to store date & time for simple usage, for example storing in the database, sectioned recycler view etc, but there are too many options of how to save data&time, and every article say one is better than the other.

There are Date, Calendar, LocalDateTime, Instant etc

My question is what is the current best way of storing date and time?

答案1

得分: 1

最佳方法是将日期和时间存储为毫秒。将您的日期和时间转换为毫秒并存储它。

英文:

Best way to store date and time in millisecond. Convert your date and time to millisecond and store it.

huangapple
  • 本文由 发表于 2020年10月13日 18:29:39
  • 转载请务必保留本文链接:https://go.coder-hub.com/64333467.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定