Android date-time manipulation library(Android 日期时间操作库)
问题描述
来自 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 日期时间操作库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Android 日期时间操作库
基础教程推荐
- 如何强制对超级方法进行多态调用? 2022-01-01
- 如何使用 Eclipse 检查调试符号状态? 2022-01-01
- 由于对所需库 rt.jar 的限制,对类的访问限制? 2022-01-01
- 如何在不安装整个 WTP 包的情况下将 Tomcat 8 添加到 Eclipse Kepler 2022-01-01
- Spring Boot Freemarker从2.2.0升级失败 2022-01-01
- 在螺旋中写一个字符串 2022-01-01
- 首次使用 Hadoop,MapReduce Job 不运行 Reduce Phase 2022-01-01
- Java 中保存最后 N 个元素的大小受限队列 2022-01-01
- 如何使用 Stream 在集合中拆分奇数和偶数以及两者的总和 2022-01-01
- 如何对 HashSet 进行排序? 2022-01-01