java.time.MonthDay.from(TemporalAccessor temporal)
方法从temporal
对象获取MonthDay
的实例。
声明
以下是java.time.MonthDay.from(TemporalAccessor temporal)
方法的声明。
public static MonthDay from(TemporalAccessor temporal)
参数
temporal
- 要转换的时间对象,不能为null
。
返回值
本地日期,不能为null
。
异常
DateTimeException
- 如果无法转换为MonthDay。
示例
以下示例显示了java.time.MonthDay.from(TemporalAccessor temporal)
方法的用法。
package com.zaixian;
import java.time.MonthDay;
import java.time.ZonedDateTime;
public class MonthDayDemo {
public static void main(String[] args) {
MonthDay date = MonthDay.from(ZonedDateTime.now());
System.out.println(date);
}
}
编译并运行上面的程序,这将产生以下结果 -
--12-26
上一篇:
java.time.MonthDay类
下一篇:
java.time.OffsetDateTime类