The java.time.LocalTime class is an immutable class 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. This class does not store or represent a date or time-zone. Instead, it is a description of the local time as seen on a wall clock. It cannot represent an instant on the time-line without additional information such as an offset or time-zone.
Java LocalTime class methods
LocalDateTime atDate(LocalDate date)
It is used to combine this time with a date to create a LocalDateTime.
int compareTo(LocalTime other)
It is used to compare this time to another time.
String format(DateTimeFormatter formatter)
It is used to format this time using the specified formatter.
int get(TemporalField field)
It is used to get the value of the specified field from this time as an int.
LocalTime minusHours(long hoursToSubtract)
It is used to return a copy of this LocalTime with the specified number of hours subtracted.
LocalTime minusMinutes(long minutesToSubtract)
It is used to return a copy of this LocalTime with the specified number of minutes subtracted.
static LocalTime now()
It is used to obtain the current time from the system clock in the default time-zone.
static LocalTime of(int hour, int minute, int second)
It is used to obtain an instance of LocalTime from an hour, minute and second.
LocalTime plusHours(long hoursToAdd)
It is used to return a copy of this LocalTime with the specified number of hours added.
LocalTime plusMinutes(long minutesToAdd)
It is used to return a copy of this LocalTime with the specified number of minutes added.