Java Date Time - DayOfWeek getValue() example








DayOfWeek getValue() gets the day-of-week int value.

Syntax

getValue has the following syntax.

public int getValue()

Example

The following example shows how to use getValue.

import java.time.DayOfWeek;
import java.time.LocalDate;
import java.time.Month;
/*ww  w .j  av a  2  s . c om*/
public class Main {
  public static void main(String[] args) {
    LocalDate localDate = LocalDate.of(2014, Month.JUNE, 21);
    DayOfWeek dayOfWeek = DayOfWeek.from(localDate);
    System.out.println(dayOfWeek.name());
    System.out.println(dayOfWeek.getValue());
    System.out.println(dayOfWeek.ordinal());
  }
}

The code above generates the following result.