CKTIS / Java
time.LocalTime: practical reference
time.LocalTime: practical reference: LocalTime models time-of-day without date, offset, or zone and has nanosecond precision.
Version: Java SE 21 (JLS and Java SE API); examples verified on the repository Java runtime
Syntax
java.time.LocalTimeLocalTime models time-of-day without date, offset, or zone and has nanosecond precision.
Use LocalTime for a recurring wall-clock time such as an opening hour when neither a date nor a zone belongs to the value.
LocalTime cannot identify an instant or an elapsed amount. plusHours and plusNanos wrap within a 24-hour day without reporting how many dates were crossed.
MIDNIGHT and MIN are both 00:00, while MAX is 23:59:59.999999999. Converting to an instant requires a date and an offset or zone.
The example exercises the documented element in a small deterministic program and compares exact standard output.
Examples
public class Main {
public static void main(String[] args) throws Exception {
var value = java.time.LocalTime.of(23, 59).plusMinutes(2);
System.out.println(value);
}
}
Result
00:01
The example exercises the documented element in a small deterministic program and compares exact standard output.