10:15:30
.
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
.
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.
The ISO-8601 calendar system is the modern civil calendar system used today in most of the world. This API assumes that all calendar systems use the same representation, this class, for time-of-day.
This is a value-based
class; programmers should treat instances that are
equal as interchangeable and should not
use instances for synchronization, or unpredictable behavior may
occur. For example, in a future release, synchronization may fail.
The equals
method should be used for comparisons.
Implementation Specification
This class is immutable and thread-safe.
Modifier and Type | Field and Description |
---|---|
private final byte | hour
The hour. |
private static final LocalTime[] | HOURS
Constants for the local time of each hour. |
pack-priv static final int | HOURS_PER_DAY
Hours per day. |
public static final LocalTime | MAX
The maximum supported |
pack-priv static final long | MICROS_PER_DAY
Microseconds per day. |
pack-priv static final long | MICROS_PER_SECOND
Microseconds per second. |
public static final LocalTime | MIDNIGHT
The time of midnight at the start of the day, '00:00'. |
pack-priv static final long | MILLIS_PER_DAY
Milliseconds per day. |
pack-priv static final long | MILLIS_PER_SECOND
Milliseconds per second. |
public static final LocalTime | MIN
The minimum supported |
private final byte | minute
The minute. |
pack-priv static final int | MINUTES_PER_DAY
Minutes per day. |
pack-priv static final int | MINUTES_PER_HOUR
Minutes per hour. |
private final int | nano
The nanosecond. |
pack-priv static final long | NANOS_PER_DAY
Nanos per day. |
pack-priv static final long | NANOS_PER_HOUR
Nanos per hour. |
pack-priv static final long | NANOS_PER_MILLI
Nanos per millisecond. |
pack-priv static final long | NANOS_PER_MINUTE
Nanos per minute. |
pack-priv static final long | NANOS_PER_SECOND
Nanos per second. |
public static final LocalTime | NOON
The time of noon in the middle of the day, '12:00'. |
private final byte | second
The second. |
pack-priv static final int | SECONDS_PER_DAY
Seconds per day. |
pack-priv static final int | SECONDS_PER_HOUR
Seconds per hour. |
pack-priv static final int | SECONDS_PER_MINUTE
Seconds per minute. |
private static final long | serialVersionUID
Serialization version. |
Access | Constructor and Description |
---|---|
private | LocalTime(int
the hour-of-day to represent, validated from 0 to 23 hour, int the minute-of-hour to represent, validated from 0 to 59 minute, int the second-of-minute to represent, validated from 0 to 59 second, int the nano-of-second to represent, validated from 0 to 999,999,999 nanoOfSecond)Constructor, previously validated. |
Modifier and Type | Method and Description |
---|---|
public Temporal | Returns: the adjusted object, not nullthe target object to be adjusted, not null temporal)Implements java. Adjusts the specified temporal object to have the same time as this object. |
public LocalDateTime | |
public OffsetTime | Returns: the offset time formed from this time and the specified offset, not nullthe offset to combine with, not null offset)Combines this time with an offset to create an |
public int | Returns: the comparator value, that is less than zero if this is beforeother ,
zero if they are equal, or greater than zero if this is after other the other time to compare to, not null other)Implements java. Compares this time to another time. |
private static LocalTime | Returns: the local time, not nullthe hour-of-day to represent, validated from 0 to 23 hour, int the minute-of-hour to represent, validated from 0 to 59 minute, int the second-of-minute to represent, validated from 0 to 59 second, int the nano-of-second to represent, validated from 0 to 999,999,999 nanoOfSecond)Creates a local time from the hour, minute, second and nanosecond fields. |
public boolean | Returns: true if this is equal to the other timethe object to check, null returns false obj)Overrides java. Checks if this time is equal to another time. |
public String | Returns: the formatted time string, not nullthe formatter to use, not null formatter)Formats this time using the specified formatter. |
public static LocalTime | Returns: the local time, not nullthe temporal object to convert, not null temporal)Obtains an instance of |
public int | Returns: the value for the fieldthe field to get, not null field)Overrides default java. Gets the value of the specified field from this time as an |
private int | |
public int | |
public long | Returns: the value for the fieldthe field to get, not null field)Implements java. Gets the value of the specified field from this time as a |
public int | |
public int | |
public int | |
public int | Returns: a suitable hash codeOverrides java. A hash code for this time. |
public boolean | |
public boolean | |
public boolean | Returns: true if the field is supported on this time, false if notthe field to check, null returns false field)Implements java. Checks if the specified field is supported. |
public boolean | Returns: true if the unit can be added/subtracted, false if notthe unit to check, null returns false unit)Implements java. Checks if the specified unit is supported. |
public LocalTime | Returns: aLocalTime based on this time with the subtraction made, not nullthe amount to subtract, not null amountToSubtract)Overrides default java. Returns a copy of this time with the specified amount subtracted. |
public LocalTime | Returns: aLocalTime based on this time with the specified amount subtracted, not nullthe amount of the unit to subtract from the result, may be negative amountToSubtract, TemporalUnit the unit of the amount to subtract, not null unit)Overrides default java. Returns a copy of this time with the specified amount subtracted. |
public LocalTime | Returns: aLocalTime based on this time with the hours subtracted, not nullthe hours to subtract, may be negative hoursToSubtract)Returns a copy of this |
public LocalTime | Returns: aLocalTime based on this time with the minutes subtracted, not nullthe minutes to subtract, may be negative minutesToSubtract)Returns a copy of this |
public LocalTime | Returns: aLocalTime based on this time with the nanoseconds subtracted, not nullthe nanos to subtract, may be negative nanosToSubtract)Returns a copy of this |
public LocalTime | Returns: aLocalTime based on this time with the seconds subtracted, not nullthe seconds to subtract, may be negative secondsToSubtract)Returns a copy of this |
public static LocalTime | Returns: the current time using the system clock and default time-zone, not nullObtains the current time from the system clock in the default time-zone. |
public static LocalTime | |
public static LocalTime | |
public static LocalTime | Returns: the local time, not nullthe hour-of-day to represent, from 0 to 23 hour, int the minute-of-hour to represent, from 0 to 59 minute)Obtains an instance of |
public static LocalTime | Returns: the local time, not nullthe hour-of-day to represent, from 0 to 23 hour, int the minute-of-hour to represent, from 0 to 59 minute, int the second-of-minute to represent, from 0 to 59 second)Obtains an instance of |
public static LocalTime | Returns: the local time, not nullthe hour-of-day to represent, from 0 to 23 hour, int the minute-of-hour to represent, from 0 to 59 minute, int the second-of-minute to represent, from 0 to 59 second, int the nano-of-second to represent, from 0 to 999,999,999 nanoOfSecond)Obtains an instance of |
public static LocalTime | |
public static LocalTime | Returns: the local time, not nullthe nano of day, from nanoOfDay)0 to 24 * 60 * 60 * 1,000,000,000 - 1 Obtains an instance of |
public static LocalTime | Returns: the local time, not nullthe second-of-day, from secondOfDay)0 to 24 * 60 * 60 - 1 Obtains an instance of |
public static LocalTime | Returns: the parsed local time, not nullthe text to parse such as "10:15:30", not null text)Obtains an instance of |
public static LocalTime | Returns: the parsed local time, not nullthe text to parse, not null text, DateTimeFormatter the formatter to use, not null formatter)Obtains an instance of |
public LocalTime | Returns: aLocalTime based on this time with the addition made, not nullthe amount to add, not null amountToAdd)Overrides default java. Returns a copy of this time with the specified amount added. |
public LocalTime | Returns: aLocalTime based on this time with the specified amount added, not nullthe amount of the unit to add to the result, may be negative amountToAdd, TemporalUnit the unit of the amount to add, not null unit)Implements java. Returns a copy of this time with the specified amount added. |
public LocalTime | Returns: aLocalTime based on this time with the hours added, not nullthe hours to add, may be negative hoursToAdd)Returns a copy of this |
public LocalTime | Returns: aLocalTime based on this time with the minutes added, not nullthe minutes to add, may be negative minutesToAdd)Returns a copy of this |
public LocalTime | Returns: aLocalTime based on this time with the nanoseconds added, not nullthe nanos to add, may be negative nanosToAdd)Returns a copy of this |
public LocalTime | Returns: aLocalTime based on this time with the seconds added, not nullthe seconds to add, may be negative secondstoAdd)Returns a copy of this |
public < the type of the result R> R | Returns: the query result, null may be returned (defined by the query)the query to invoke, not null query)Overrides default java. Queries this time using the specified query. |
public ValueRange | Returns: the range of valid values for the field, not nullthe field to query the range for, not null field)Overrides default java. Gets the range of valid values for the specified field. |
pack-priv static LocalTime | |
private void | |
public long | Returns: the number of seconds since the epoch of 1970-01-01T00:00:00Z, may be negativethe local date, not null date, ZoneOffset the zone offset, not null offset)Converts this |
public long | Returns: the nano of day equivalent to this timeExtracts the time as nanos of day,
from |
public int | Returns: the second-of-day equivalent to this timeExtracts the time as seconds of day,
from |
public String | Returns: a string representation of this time, not nullOverrides java. Outputs this time as a |
public LocalTime | Returns: aLocalTime based on this time with the time truncated, not nullthe unit to truncate to, not null unit)Returns a copy of this |
public long | Returns: the amount of time between this time and the end timethe end time, exclusive, which is converted to a endExclusive, TemporalUnit LocalTime , not nullthe unit to measure the amount in, not null unit)Implements java. Calculates the amount of time until another time in terms of the specified unit. |
public LocalTime | Returns: aLocalTime based on this with the adjustment made, not nullthe adjuster to use, not null adjuster)Overrides default java. Returns an adjusted copy of this time. |
public LocalTime | Returns: aLocalTime based on this with the specified field set, not nullthe field to set in the result, not null field, long the new value of the field in the result newValue)Implements java. Returns a copy of this time with the specified field set to a new value. |
public LocalTime | Returns: aLocalTime based on this time with the requested hour, not nullthe hour-of-day to set in the result, from 0 to 23 hour)Returns a copy of this |
public LocalTime | Returns: aLocalTime based on this time with the requested minute, not nullthe minute-of-hour to set in the result, from 0 to 59 minute)Returns a copy of this |
public LocalTime | Returns: aLocalTime based on this time with the requested nanosecond, not nullthe nano-of-second to set in the result, from 0 to 999,999,999 nanoOfSecond)Returns a copy of this |
public LocalTime | Returns: aLocalTime based on this time with the requested second, not nullthe second-of-minute to set in the result, from 0 to 59 second)Returns a copy of this |
pack-priv void | |
private Object | Returns: the instance ofSer , not nullWrites the object using a dedicated serialized form. |