java.time.MonthDay
1 java.time.MonthDay介绍
Java MonthDay类是一个不变的日期时间对象,它代表月份和月份的组合。它继承了Object类并实现Comparable接口。
2 java.time.MonthDay声明
我们来看一下java.time.MonthDay类的声明。
public final class MonthDay extends Object implements TemporalAccessor, TemporalAdjuster, Comparable<MonthDay>, Serializable
3 java.time.MonthDay方法
4 java.time.MonthDay案例1
package com.yiidian;
/**
* 一点教程网: http://www.yiidian.com
*/
import java.time.*;
public class MonthDayExample1 {
public static void main(String[] args) {
MonthDay month = MonthDay.now();
LocalDate date = month.atYear(1994);
System.out.println(date);
}
}
输出结果为:
1994-01-17
5 java.time.MonthDay案例2
package com.yiidian;
/**
* 一点教程网: http://www.yiidian.com
*/
import java.time.*;
public class MonthDayExample2 {
public static void main(String[] args) {
MonthDay month = MonthDay.now();
boolean b = month.isValidYear(2012);
System.out.println(b);
}
}
输出结果为:
true
热门文章
优秀文章