java.time.YearMonth.atEndOfMonth()
方法在月末返回LocalDate
。
声明
以下是java.time.YearMonth.atEndOfMonth()
方法的声明。
public LocalDate atEndOfMonth()
返回值
此年月的最后一个有效日期,不为null
。
示例
以下示例显示了java.time.YearMonth.atEndOfMonth()
方法的用法。
package com.yiibai;
import java.time.LocalDate;
import java.time.YearMonth;
public class YearMonthDemo {
public static void main(String[] args) {
YearMonth date = YearMonth.of(2015,12);
LocalDate date1 = date.atEndOfMonth();
System.out.println(date1);
}
}
编译并运行上面的程序,这将产生以下结果 -
2015-12-31