java.time.LocalTime;
时间: 2024-05-22 14:12:55 浏览: 91
java.time.LocalTime is a class in the Java 8 Date/Time API that represents a time without a date or time zone information. It is immutable and thread-safe, and provides various utility methods for working with time values.
Some examples of creating a LocalTime object are:
- LocalTime now() - returns the current system time
- LocalTime.of(int hour, int minute, int second) - creates a LocalTime with specified hour, minute and second values
- LocalTime.parse(CharSequence text) - parses a string into a LocalTime object
Some important methods in LocalTime class are:
- plusHours(long hoursToAdd) - returns a new LocalTime object with the specified number of hours added
- minusMinutes(long minutesToSubtract) - returns a new LocalTime object with the specified number of minutes subtracted
- getHour() - returns the hour value of the LocalTime object
- getMinute() - returns the minute value of the LocalTime object
- isAfter(LocalTime other) - checks if the current LocalTime object is after the specified LocalTime object
- format(DateTimeFormatter formatter) - formats the LocalTime object using the specified formatter.
阅读全文