Java Date Time - DayOfWeek getLong(TemporalField field) example








DayOfWeek getLong(TemporalField field) gets the value of the specified field from this day-of-week as a long.

Syntax

getLong has the following syntax.

public long getLong(TemporalField field)

Example

The following example shows how to use getLong.

import java.time.DayOfWeek;
import java.time.LocalDate;
import java.time.Month;
import java.time.temporal.ChronoField;
/*w  ww.  j a v a 2s  . 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.getLong(ChronoField.DAY_OF_WEEK));
  }
}

The code above generates the following result.