The getNano() method of OffsetDateTime class in Java gets the nano-of-second field.
Syntax :
public int getNano()
Parameter : This method does not accepts any parameter.
Return Value: It returns the nano-of-second which ranges from 0 to 999, 999, 999.
Below programs illustrate the getNano() method:
Program 1 :
import java.time.OffsetDateTime;
public class GFG {
public static void main(String[] args)
{
OffsetDateTime date = OffsetDateTime.parse( "2018-12-03T12:30:30+01:00" );
System.out.println( "nano-second: " + date.getNano());
}
}
|
Program 2 :
import java.time.OffsetDateTime;
public class GFG {
public static void main(String[] args)
{
OffsetDateTime date = OffsetDateTime.parse( "2016-10-03T12:30:30+01:20" );
System.out.println( "nano-second: " + date.getNano());
}
}
|
Reference: https://docs.oracle.com/javase/8/docs/api/java/time/OffsetDateTime.html#getNano–