- java.time 包類
- java.time - 首頁
- java.time - 時鐘
- java.time - 持續時間
- java.time - 即時
- java.time - LocalDate
- java.time - LocalDateTime
- java.time - LocalTime
- java.time - MonthDay
- java.time - OffsetDateTime
- java.time - OffsetTime
- java.time - Period
- java.time - 年
- java.time - 年月
- java.time - ZonedDateTime
- java.time - 時區 ID
- java.time - 時區偏移
- java.time 包列舉
- java.time - 月
- java.time 有用資源
- java.time - 討論
java.time.MonthDay.from() 方法示例
描述
java.time.MonthDay.from(TemporalAccessor temporal) 方法從時間物件獲取 MonthDay 例項。
宣告
以下是 java.time.MonthDay.from(TemporalAccessor temporal) 方法的宣告。
public static MonthDay from(TemporalAccessor temporal)
引數
temporal - 要轉換的時間物件,非空。
返回值
MonthDay 例項,非空。
異常
DateTimeException - 如果無法轉換到 MonthDay。
示例
以下示例展示了 java.time.MonthDay.from(TemporalAccessor temporal) 方法的用法。
package com.tutorialspoint;
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
廣告