Java Date Time - LocalDateTime getLong(TemporalField field) example








LocalDateTime getLong(TemporalField field) gets the value of the specified field from this date-time 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.LocalDateTime;
import java.time.temporal.ChronoField;
// w w w.j  a v  a2  s .co  m
public class Main {
  public static void main(String[] args) {
    LocalDateTime a = LocalDateTime.of(2014, 6, 30, 12, 01);
    
    System.out.println(a.getLong(ChronoField.DAY_OF_WEEK));
  }
}

The code above generates the following result.