LocalTime
suggest changeVersions
The original version list named Java SE 8 and 9 (Early Access).
Syntax
- LocalTime time = LocalTime.now(); // Initializes with current system clock
- LocalTime time = LocalTime.MIDNIGHT; // 00:00
- LocalTime time = LocalTime.NOON; // 12:00
- LocalTime time = LocalTime.of(12, 12, 45); // 12:12:45
Parameters
| Method | Output |
|---|---|
LocalTime.of(13, 12, 11) |
13:12:11 |
LocalTime.MIDNIGHT |
00:00 |
LocalTime.NOON |
12:00 |
LocalTime.now() |
Current time from system clock |
LocalTime.MAX |
The maximum supported local time 23:59:59.999999999 |
LocalTime.MIN |
The minimum supported local time 00:00 |
LocalTime.ofSecondOfDay(84399) |
23:26:39. Obtains the time from a second-of-day value. |
LocalTime.ofNanoOfDay(2000000000) |
00:00:02. Obtains the time from a nanos-of-day value. |
Remarks
As the class name denotes, LocalTime represents a time without a time-zone. It doesn’t represent a date. It’s a simple label for a given time.
The class is value-based and the equals method should be used when doing comparisons.
This class is from the package java.time.
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents