LocalTime getNano() method in Java with Examples
Last Updated :
03 Dec, 2018
The getNano() method of a LocalTime class is used to return the nano-of-second field. This method returns an integer value ranging from 0 to 999,999,999, i.e. the Nanos of a second.
Syntax:
public int getNano()
Parameters: This method does not accept any parameter.
Return value: This method returns an integer value which represents nano-of-second and it ranges from 0 to 999,999,999.
Below programs illustrate the getNano() method:
Program 1:
import java.time.*;
public class GFG {
public static void main(String[] args)
{
LocalTime time
= LocalTime.parse( "19:34:50.63" );
int Nano = time.getNano();
System.out.println( "Nano Field: "
+ Nano);
}
}
|
Output:
Nano Field: 630000000
Program 2:
import java.time.*;
public class GFG {
public static void main(String[] args)
{
LocalTime time
= LocalTime.parse( "23:14:30.53" );
int Nano = time.getNano();
System.out.println( "Nano Field: "
+ Nano);
}
}
|
Output:
Nano Field: 530000000
Reference: https://docs.oracle.com/javase/10/docs/api/java/time/LocalTime.html#getNano()
Share your thoughts in the comments
Please Login to comment...