Javatime-localdatetime-getdayofweek
提供:Dev Guides
java.time.LocalDateTime.getDayOfWeek()メソッドの例
説明
- java.time.LocalDateTime.getDayOfWeek()*メソッドは、DayDayOfWeek列挙型である曜日フィールドを取得します。
宣言
以下は* java.time.LocalDateTime.getDayOfWeek()*メソッドの宣言です。
public DayOfWeek getDayOfWeek()
戻り値
曜日、null以外。
例
次の例は、java.time.LocalDateTime.getDayOfWeek()メソッドの使用法を示しています。
package com.finddevguides;
import java.time.LocalDateTime;
public class LocalDateTimeDemo {
public static void main(String[] args) {
LocalDateTime date = LocalDateTime.parse("2017-02-03T12:30:30");
System.out.println(date.getDayOfWeek());
}
}
上記のプログラムをコンパイルして実行すると、次の結果が生成されます-
FRIDAY