更新时间:2022-05-24 23:05:09
java.time.MonthDay
在 ThreeTenABP 项目,它是 = nofollow noreferrer> Java时间类内置于Java 8及更高版本中。避免麻烦的旧式旧式日期时间类。
java.time.MonthDay
Use modern date-time classes in the ThreeTenABP project, an Android adaptation of the back-port of the java-time classes built into Java 8 and later. Avoid the troublesome old legacy date-time classes.
这些java.time类包括 MonthDay
类代表一个月和一个月中的某天
These java.time classes include the MonthDay
class to represent a month and a day-of-month without a year.
MonthDay md = MonthDay.of( 8 , 15 );
此类已实现 可比较
接口及其 compareTo
方法。还实现了 等于
, isBefore
和 isAfter
。因此,工作就完成了。
This class already implements the Comparable
interface and its compareTo
method. Also implements methods equals
, isBefore
, and isAfter
. So, job done.
确定当前 MonthDay
需要一个时区。在任何给定的时刻,日期都会根据时区。
ZoneId z = ZoneId.of( "America/Montreal" );
MonthDay today = MonthDay.now( z );
java.time 框架内置于Java 8及更高版本中。这些类取代了麻烦的旧旧版日期时间类,例如 java.util.Date
, Calendar
,& SimpleDateFormat
。
The java.time framework is built into Java 8 and later. These classes supplant the troublesome old legacy date-time classes such as java.util.Date
, Calendar
, & SimpleDateFormat
.
现在处于维护模式的Joda-Time 项目建议迁移到 java.time 类。
The Joda-Time project, now in maintenance mode, advises migration to the java.time classes.
要了解更多信息,请参见 Oracle教程。并在Stack Overflow中搜索许多示例和说明。规范为 JSR 310 。
To learn more, see the Oracle Tutorial. And search Stack Overflow for many examples and explanations. Specification is JSR 310.
从哪里获取java.time类?
Where to obtain the java.time classes?