java.time.LocalTime.toNanoOfDay() Method Example



Description

The java.time.LocalTime.toNanoOfDay() method extracts the time as nanos of day, from 0 to 24 * 60 * 60 * 1,000,000,000 - 1.

Declaration

Following is the declaration for java.time.LocalTime.toNanoOfDay() method.

public long toNanoOfDay()

Return Value

the nano of day equivalent to this time.

Example

The following example shows the usage of java.time.LocalTime.toNanoOfDay() method.

package com.tutorialspoint;

import java.time.LocalTime;

public class LocalTimeDemo {
   public static void main(String[] args) {
 
      LocalTime time = LocalTime.now();
      System.out.println(time.toNanoOfDay());  
   }
}

Let us compile and run the above program, this will produce the following result −

52646592000000
Advertisements