DayOfWeek getValue() example

Description

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;
/*from  w  ww. j  ava 2 s .  c o m*/
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.





















Home »
  Java Date Time »
    java.time Reference »




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