Java Date Time - OffsetDateTime getDayOfWeek() example








OffsetDateTime getDayOfWeek() gets the day-of-week field, which is an enum DayOfWeek.

Syntax

getDayOfWeek has the following syntax.

public DayOfWeek getDayOfWeek()

Example

The following example shows how to use getDayOfWeek.

import java.time.DayOfWeek;
import java.time.OffsetDateTime;
/*w  w w .j a v  a2s  . c  o m*/
public class Main {
  public static void main(String[] args) {
    OffsetDateTime o = OffsetDateTime.now();
    DayOfWeek l = o.getDayOfWeek();
    System.out.println(l);
  }
}

The code above generates the following result.