来自 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模板网!
解析 ISO 8601 字符串本地日期时间,就像在 UTC 中Parsing an ISO 8601 string local date-time as if in UTC(解析 ISO 8601 字符串本地日期时间,就像在 UTC 中一样)
如何将公历字符串转换为公历?How to convert Gregorian string to Gregorian Calendar?(如何将公历字符串转换为公历?)
Java:GregorianCalendar 的最大值和最小值是什么/在哪Java: What/where are the maximum and minimum values of a GregorianCalendar?(Java:GregorianCalendar 的最大值和最小值是什么/在哪里?)
1582 年 10 月 15 日之前日期的日历到日期转换.公历Calendar to Date conversion for dates before 15 Oct 1582. Gregorian to Julian calendar switch(1582 年 10 月 15 日之前日期的日历到日期转换
java日历setFirstDayOfWeek不起作用java Calendar setFirstDayOfWeek not working(java日历setFirstDayOfWeek不起作用)
Java:获取当前星期几的值Java: getting current Day of the Week value(Java:获取当前星期几的值)