This method extracts and returns the specified temporal field value as long.
This method will also throw the exception for the field which returns false from LocalTime.isSupported(TemporalField)
method.
package com.logicbig.example.localtime;
import java.time.LocalTime;
import java.time.temporal.ChronoField;
public class GetLongExample {
public static void main (String... args) {
LocalTime d = LocalTime.of(14, 30, 40, 3000);
long i = d.getLong(ChronoField.NANO_OF_DAY);
System.out.printf("NANO_OF_DAY: %d%n", i);
i = d.getLong(ChronoField.MICRO_OF_DAY);
System.out.printf("MICRO_OF_DAY: %d%n", i);
}
}
Output
NANO_OF_DAY: 52240000003000
MICRO_OF_DAY: 52240000003