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 日期时间操作库
基础教程推荐
- 修改 void 函数的输入参数,然后读取 2022-01-01
- 无法复制:“比较方法违反了它的一般约定!" 2022-01-01
- Spring AOP错误无法懒惰地为此建议构建thisJoinPoin 2022-09-13
- REST Web 服务返回 415 - 不支持的媒体类型 2022-01-01
- 使用堆栈算法进行括号/括号匹配 2022-01-01
- 问题http://apache.org/xml/features/xinclude测试日志4j 2 2022-01-01
- RabbitMQ:消息保持“未确认"; 2022-01-01
- 如何对 Java Hashmap 中的值求和 2022-01-01
- Struts2 URL 无法访问 2022-01-01
- 存储 20 位数字的数据类型 2022-01-01
