- java.time 包類
- java.time - 主頁
- java.time - Clock
- java.time - Duration
- java.time - Instant
- java.time - LocalDate
- java.time - LocalDateTime
- java.time - LocalTime
- java.time - MonthDay
- java.time - OffsetDateTime
- java.time - OffsetTime
- java.time - Period
- java.time - Year
- java.time - YearMonth
- java.time - ZonedDateTime
- java.time - ZoneId
- java.time - ZoneOffset
- java.time 包列舉
- java.time - Month
- java.time 使用教程
- java.time - 討論
java.time.Month.of() 方法示例
說明
**java.time.Month.of(String month)** 方法從 int 值獲取 Month 的例項。
宣告
以下是 **java.time.Month.of(String month)** 方法的宣告。
public static Month of(String month)
public static Month of(String month)
引數
**month** - 要表示的月份,從 1(1 月)到 12(12 月)
返回值
月份,非空。
異常
**DateTimeException** - 如果月份無效。
示例
package com.tutorialspoint;
import java.time.Month;
public class MonthDemo {
public static void main(String[] args) {
Month month = Month.of(3);
System.out.println(month);
}
}
現場演示
MARCH
列印本頁