Close

Java Date Time - LocalDate.getLong() Examples

Java Date Time Java Java API 


Class:

java.time.LocalDate

java.lang.Objectjava.lang.Objectjava.time.LocalDatejava.time.LocalDatejava.time.temporal.TemporalTemporaljava.time.temporal.TemporalAdjusterTemporalAdjusterjava.time.chrono.ChronoLocalDateChronoLocalDatejava.io.SerializableSerializableLogicBig

Method:

public long getLong(TemporalField field)

This method extracts and returns the specified temporal field value as long.

This method is different from get(TemporalField) in that it won't throw UnsupportedTemporalTypeException for fields EPOCH_DAY and PROLEPTIC_MONTH.

It will also throw the exception for the field which returns false from LocalDate.isSupported(TemporalField) method.

This method is defined in the interface, TemporalAccessor


Examples


package com.logicbig.example.localdate;

import java.time.LocalDate;
import java.time.temporal.ChronoField;

public class GetLongExample {

public static void main (String... args) {
long l = LocalDate.of(2012, 11, 15)
.getLong(ChronoField.EPOCH_DAY);
System.out.println(l);

}
}

Output

15659




See Also