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 日期时间操作库
基础教程推荐
- Java Swing计时器未清除 2022-01-01
- 如何在 JFrame 中覆盖 windowsClosing 事件 2022-01-01
- Java 实例变量在两个语句中声明和初始化 2022-01-01
- 大摇大摆的枚举 2022-01-01
- 验证是否调用了所有 getter 方法 2022-01-01
- 在 Java 中创建日期的正确方法是什么? 2022-01-01
- 不推荐使用 Api 注释的描述 2022-01-01
- 从 python 访问 JVM 2022-01-01
- 如何在 Spring @Value 注解中正确指定默认值? 2022-01-01
- 多个组件的复杂布局 2022-01-01
