ZonedDateTime getDayOfWeek() example

Description

ZonedDateTime getDayOfWeek() gets the day-of-week field, which is an enum DayOfWeek. This method returns the enum DayOfWeek for the day-of-week. This avoids confusion as to what int values mean. If you need access to the primitive int value then the enum provides the int value. Additional information can be obtained from the DayOfWeek. This includes textual names of the values.

Syntax

getDayOfWeek has the following syntax.


public DayOfWeek getDayOfWeek()

Example

The following example shows how to use getDayOfWeek.


import java.time.ZonedDateTime;
// w w  w .jav a 2 s  . co  m
public class Main {
  public static void main(String[] args) {
    ZonedDateTime dateTime =ZonedDateTime.now();

    System.out.println(dateTime.getDayOfWeek());
  } 
}

The code above generates the following result.





















Home »
  Java Date Time »
    java.time Reference »




Clock
DayOfWeek
Duration
Instant
LocalDate
LocalDateTime
LocalTime
Month
MonthDay
OffsetDateTime
OffsetTime
Period
Year
YearMonth
ZonedDateTime
ZoneId
ZoneOffset