来自 C#,我习惯了光滑的界面 DateTime
和 TimeSpan
报价.有了这些,我可以访问日期时间部分(年、月、秒等)、基础刻度、减去日期、添加时间增量等等.
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.
是否有一个等效的 Java 库来简化 Android 中 Date
对象的操作?
Is there an equivalent Java library to ease the manipulation of Date
objects in Android?
更新:
正如@basil 在下面的评论中指出的那样
As @basil pointed out in the comment below
Joda-Time 项目现在处于维护模式.它的创建者 Stephen Colebourne 继续领导 JSR 310 定义 Java 8+ 中内置的 java.time 类.请参阅 Oracle 教程.– Basil Bourque 1 分钟前
The Joda-Time project is now in maintenance mode. Its creator, Stephen Colebourne, went on to lead JSR 310 defining the java.time classes built into Java 8+. See Tutorial by Oracle. – Basil Bourque 1 min ago
你可以使用 joda-time 它是一个外部库,Date &日历是提供的基本 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 日期时间操作库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!