LocalTime is an immutable date-time object that represents a time, often viewed as hour-minute-second. Time is represented to nanosecond precision. For example, the value "13:45.30.123456789" can be stored in a LocalTime.
The method toSecondOfDay() and toNanoOfDay() extracts the time as seconds of day/nanos of day.
Example:
package java8localtime;
import java.time.LocalTime;
/**
* @web http://java-buddy.blogspot.com/
*/
public class Java8LocalTime {
public static void main(String[] args) {
LocalTime now = LocalTime.now();
System.out.println("now.toString(): " + now.toString());
System.out.println("now.toSecondOfDay(): " + now.toSecondOfDay());
System.out.println("now.toNanoOfDay(): " + now.toNanoOfDay());
}
}
![]() |
| Get second of Day and nano decond of day with LocalTime |

No comments:
Post a Comment