LocalTime getNano() method in Java with Examples
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:
// Java program to demonstrate // LocalTime.getNano() method import java.time.*; public class GFG { public static void main(String[] args) { // create a LocalTime object LocalTime time = LocalTime.parse("19:34:50.63"); // get Nano field using getNano() int Nano = time.getNano(); // print result System.out.println("Nano Field: " + Nano); } } |
Nano Field: 630000000
Program 2:
// Java program to demonstrate // LocalTime.getNano() method import java.time.*; public class GFG { public static void main(String[] args) { // create a LocalTime object LocalTime time = LocalTime.parse("23:14:30.53"); // get Nano field using getNano() int Nano = time.getNano(); // print result System.out.println("Nano Field: " + Nano); } } |
Nano Field: 530000000
Reference: https://docs.oracle.com/javase/10/docs/api/java/time/LocalTime.html#getNano()
Recommended Posts:
- Duration getNano() method in Java with Examples
- OffsetDateTime getNano() method in Java with examples
- OffsetTime getNano() method in Java with examples
- Instant getNano() method in Java with Examples
- LocalDateTime getNano() method in Java with Examples
- ZonedDateTime getNano() method in Java with Examples
- LocalTime from() method in Java with Examples
- LocalTime with() Method in Java with Examples
- LocalTime plus() method in Java with Examples
- LocalTime until() Method in Java with Examples
- LocalTime get() method in Java with Examples
- LocalTime toEpochSecond() method in Java with Examples
- LocalTime plusMinutes() method in Java with Examples
- LocalTime plusSeconds() method in Java with Examples
- LocalTime getSecond() method in Java with Examples
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



