Android日期时间操纵库 [英] Android date-time manipulation library
问题描述
来自C#,我习惯了光滑的界面 DateTime
和 TimeSpan
优惠。有了这些,我可以访问日期时间部分(年,月,秒等),底层Ticks,减去日期,添加时间增量等。
Coming from C#, I got used to the slick interface DateTime
and TimeSpan
offer. With these, I can access date-time parts (Year, Month, Seconds, etc.), the underlying Ticks, subtract dates, add time deltas and so on.
作为Java / Android新手,我了解等效的Java Date
类用于拥有这些访问器,但由于反向兼容性原因而被删除。建议的替代方法是使用 Calendar
对象,但是我发现它的界面比.Net的更麻烦。
As a Java/Android newbie, I understand that the equivalent Java Date
class used to have these accessors, but they were removed for back-compatibility reasons. The suggested alternative is to use a Calendar
object, but I find its interface cumbersome compared with .Net's.
为了方便操作Android中的 Date
对象?
Is there an equivalent Java library to ease the manipulation of Date
objects in Android?
推荐答案
使用 joda-time 它是一个外部图书馆,日期&日历是基本的API提供,与java 8它已经添加了更好的api日期时间,但对于android现在你可以使用joda tiem
you can use joda-time it is an external library, Date & Calendar are basic API provided, with java 8 it has added much better api for date time but for android for now you can use joda tiem
这篇关于Android日期时间操纵库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!