12:31.
This class is similar to LocalTime but has a precision of minutes.
Seconds and nanoseconds cannot be represented by this class.
This class must be treated as a value type. Do not synchronize, rely on the identity hash code or use the distinction between equals() and ==.
| Modifier and Type | Field and Description |
|---|---|
| private final int | hour
The hour-of-day. |
| private static final int | HOURS_PER_DAY
Hours per day. |
| public static final HourMinute | MIDNIGHT
The time of midnight at the start of the day, '00:00'. |
| private final int | minute
The minute-of-hour. |
| private static final int | MINUTES_PER_DAY
Minutes per day. |
| private static final int | MINUTES_PER_HOUR
Minutes per hour. |
| private static final DateTimeFormatter | PARSER
Parser. |
| private static final long | serialVersionUID
Serialization version. |
| Access | Constructor and Description |
|---|---|
| private | HourMinute(int
the hour to represent, validated from 0 to 23 hour, int the minute-of-hour to represent, validated from 0 to 59 minute)Constructor. |
| 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 this hour-minute. |
| 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, negative if less, positive if greaterthe other hour-minute to compare to, not null other)Implements java. Compares this hour-minute to another The comparison is based first on the value of the hour, then on the value of the minute. |
| public boolean | Returns: true if this is equal to the other hour-minutethe object to check, null returns false obj)Overrides java. Checks if this hour-minute is equal to another hour-minute. |
| public String | Returns: the formatted hour-minute string, not nullthe formatter to use, not null formatter)Formats this hour-minute using the specified formatter. |
| public static HourMinute | Returns: the hour-minute, 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 hour-minute 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 hour-minute as a |
| public int | |
| public int | Returns: a suitable hash codeOverrides java. A hash code for this hour-minute. |
| public boolean | Returns: true if this is after the specified hour-minutethe other hour-minute to compare to, not null other)Is this hour-minute after the specified hour-minute. |
| public boolean | Returns: true if this point is before the specified hour-minutethe other hour-minute to compare to, not null other)Is this hour-minute before the specified hour-minute. |
| public boolean | Returns: true if the field is supported on this hour-minute, 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 HourMinute | Returns: aHourMinute based on this hour-minute with the subtraction made, not nullthe amount to subtract, not null amountToSubtract)Overrides default java. Returns a copy of this hour-minute with the specified amount subtracted. |
| public HourMinute | Returns: aHourMinute based on this hour-minute 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 hour-minute with the specified amount subtracted. |
| public HourMinute | Returns: aHourMinute based on this hour-minute with the hours subtracted, not nullthe hours to subtract, may be negative hoursToSubtract)Returns a copy of this hour-minute with the specified period in hours subtracted. |
| public HourMinute | Returns: aHourMinute based on this hour-minute with the minutes subtracted, not nullthe minutes to subtract, may be negative minutesToSubtract)Returns a copy of this hour-minute with the specified period in minutes subtracted. |
| public static HourMinute | Returns: the current hour-minute using the system clock and default time-zone, not nullObtains the current hour-minute from the system clock in the default time-zone. |
| public static HourMinute | |
| public static HourMinute | |
| public static HourMinute | Returns: the hour-minute, not nullthe hour 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 HourMinute | Returns: the parsed hour-minute, not nullthe text to parse such as "12:31", not null text)Obtains an instance of |
| public static HourMinute | Returns: the parsed hour-minute, not nullthe text to parse, not null text, DateTimeFormatter the formatter to use, not null formatter)Obtains an instance of |
| public HourMinute | Returns: aHourMinute based on this hour-minute with the addition made, not nullthe amount to add, not null amountToAdd)Overrides default java. Returns a copy of this hour-minute with the specified amount added. |
| public HourMinute | Returns: aHourMinute based on this hour-minute 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 hour-minute with the specified amount added. |
| public HourMinute | Returns: anHourMinute based on this time with the hours added, not nullthe hours to add, may be negative hoursToAdd)Returns a copy of this |
| public HourMinute | Returns: anHourMinute based on this time with the minutes added, not nullthe minutes to add, may be negative minutesToAdd)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 hour-minute 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. |
| private Object | |
| public LocalTime | |
| public String | Returns: a string representation of this hour-minute, not nullOverrides java. Outputs this hour-minute as a |
| public long | Returns: the amount of time between this hour-minute and the end hour-minutethe end date, exclusive, which is converted to a endExclusive, TemporalUnit HourMinute, not nullthe unit to measure the amount in, not null unit)Implements java. Calculates the amount of time until another hour-minute in terms of the specified unit. |
| private HourMinute | Returns: the hour-minute, not nullthe hour to represent, validated from 0 to 23 newYear, int the minute-of-hour to represent, validated from 0 to 59 newMinute)Returns a copy of this hour-minute with the new hour and minute, checking to see if a new object is in fact required. |
| public HourMinute | Returns: aHourMinute based on this with the adjustment made, not nullthe adjuster to use, not null adjuster)Overrides default java. Returns an adjusted copy of this hour-minute. |
| public HourMinute | Returns: aHourMinute 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 hour-minute with the specified field set to a new value. |
| public HourMinute | Returns: aHourMinute based on this hour-minute with the requested hour, not nullthe hour to set in the returned hour-minute, from 0 to 23 hour)Returns a copy of this |
| public HourMinute | Returns: aHourMinute based on this hour-minute with the requested minute, not nullthe minute-of-hour to set in the returned hour-minute, from 0 to 59 minute)Returns a copy of this |
| hour | back to summary |
|---|---|
| private final int hour The hour-of-day. | |
| HOURS_PER_DAY | back to summary |
|---|---|
| private static final int HOURS_PER_DAY Hours per day. | |
| MIDNIGHT | back to summary |
|---|---|
| public static final HourMinute MIDNIGHT The time of midnight at the start of the day, '00:00'. | |
| minute | back to summary |
|---|---|
| private final int minute The minute-of-hour. | |
| MINUTES_PER_DAY | back to summary |
|---|---|
| private static final int MINUTES_PER_DAY Minutes per day. | |
| MINUTES_PER_HOUR | back to summary |
|---|---|
| private static final int MINUTES_PER_HOUR Minutes per hour. | |
| PARSER | back to summary |
|---|---|
| private static final DateTimeFormatter PARSER Parser. | |
| serialVersionUID | back to summary |
|---|---|
| private static final long serialVersionUID Serialization version. | |
| HourMinute | back to summary |
|---|---|
| private HourMinute(int hour, int minute) Constructor.
| |
| adjustInto | back to summary |
|---|---|
| public Temporal adjustInto(Temporal temporal) Implements java. Adjusts the specified temporal object to have this hour-minute. Note that if the target has a second or nanosecond field, that is not altered by this method. This returns a temporal object of the same observable type as the input with the hour and minute changed to be the same as this.
The adjustment is equivalent to using
In most cases, it is clearer to reverse the calling pattern by using
// these two lines are equivalent, but the second approach is recommended temporal = thisHourMinute.adjustInto(temporal); temporal = temporal.with(thisHourMinute); This instance is immutable and unaffected by this method call.
| |
| atDate | back to summary |
|---|---|
| public LocalDateTime atDate(LocalDate date) Combines this time with a date to create a
This returns a
| |
| atOffset | back to summary |
|---|---|
| public OffsetTime atOffset(ZoneOffset offset) Combines this time with an offset to create an
This returns an
| |
| compareTo | back to summary |
|---|---|
| public int compareTo(HourMinute other) Implements java. Compares this hour-minute to another
The comparison is based first on the value of the hour, then on the value of the minute.
It is "consistent with equals", as defined by
| |
| equals | back to summary |
|---|---|
| public boolean equals(Object obj) Overrides java. Checks if this hour-minute is equal to another hour-minute. The comparison is based on the time-line position of the hour-minute. | |
| format | back to summary |
|---|---|
| public String format(DateTimeFormatter formatter) Formats this hour-minute using the specified formatter. This hour-minute will be passed to the formatter to produce a string.
| |
| from | back to summary |
|---|---|
| public static HourMinute from(TemporalAccessor temporal) Obtains an instance of
This obtains a hour-minute based on the specified temporal.
A
The conversion extracts the
This method matches the signature of the functional interface
| |
| get | back to summary |
|---|---|
| public int get(TemporalField field) Overrides default java. Gets the value of the specified field from this hour-minute as an This queries this hour-minute for the value for the specified field. The returned value will always be within the valid range of values for the field. If it is not possible to return the value, because the field is not supported or for some other reason, an exception is thrown.
If the field is a
If the field is not a
| |
| get0 | back to summary |
|---|---|
| private int get0(TemporalField field) | |
| getHour | back to summary |
|---|---|
| public int getHour() Gets the hour field, from 0 to 23.
This method returns the hour as an
| |
| getLong | back to summary |
|---|---|
| public long getLong(TemporalField field) Implements java. Gets the value of the specified field from this hour-minute as a This queries this hour-minute for the value for the specified field. If it is not possible to return the value, because the field is not supported or for some other reason, an exception is thrown.
If the field is a
If the field is not a
| |
| getMinute | back to summary |
|---|---|
| public int getMinute() Gets the minute-of-hour field from 0 to 59.
This method returns the minute as an
| |
| hashCode | back to summary |
|---|---|
| public int hashCode() Overrides java. A hash code for this hour-minute.
| |
| isAfter | back to summary |
|---|---|
| public boolean isAfter(HourMinute other) Is this hour-minute after the specified hour-minute.
| |
| isBefore | back to summary |
|---|---|
| public boolean isBefore(HourMinute other) Is this hour-minute before the specified hour-minute.
| |
| isSupported | back to summary |
|---|---|
| public boolean isSupported(TemporalField field) Implements java. Checks if the specified field is supported.
This checks if this hour-minute can be queried for the specified field.
If false, then calling the
If the field is a
ChronoField instances will return false.
If the field is not a
| |
| isSupported | back to summary |
|---|---|
| public boolean isSupported(TemporalUnit unit) Implements java. Checks if the specified unit is supported.
This checks if the specified unit can be added to, or subtracted from, this hour-minute.
If false, then calling the
If the unit is a
ChronoUnit instances will return false.
If the unit is not a
| |
| minus | back to summary |
|---|---|
| public HourMinute minus(TemporalAmount amountToSubtract) Overrides default java. Returns a copy of this hour-minute with the specified amount subtracted.
This returns a
The calculation is delegated to the amount object by calling
This instance is immutable and unaffected by this method call.
| |
| minus | back to summary |
|---|---|
| public HourMinute minus(long amountToSubtract, TemporalUnit unit) Overrides default java. Returns a copy of this hour-minute with the specified amount subtracted.
This returns a
This method is equivalent to This instance is immutable and unaffected by this method call.
| |
| minusHours | back to summary |
|---|---|
| public HourMinute minusHours(long hoursToSubtract) Returns a copy of this hour-minute with the specified period in hours subtracted. This instance is immutable and unaffected by this method call.
| |
| minusMinutes | back to summary |
|---|---|
| public HourMinute minusMinutes(long minutesToSubtract) Returns a copy of this hour-minute with the specified period in minutes subtracted. This instance is immutable and unaffected by this method call.
| |
| now | back to summary |
|---|---|
| public static HourMinute now() Obtains the current hour-minute from the system clock in the default time-zone.
This will query the Using this method will prevent the ability to use an alternate clock for testing because the clock is hard-coded.
| |
| now | back to summary |
|---|---|
| public static HourMinute now(ZoneId zone) Obtains the current hour-minute from the system clock in the specified time-zone.
This will query the Using this method will prevent the ability to use an alternate clock for testing because the clock is hard-coded.
| |
| now | back to summary |
|---|---|
| public static HourMinute now(Clock clock) Obtains the current hour-minute from the specified clock.
This will query the specified clock to obtain the current hour-minute.
Using this method allows the use of an alternate clock for testing.
The alternate clock may be introduced using
| |
| of | back to summary |
|---|---|
| public static HourMinute of(int hour, int minute) Obtains an instance of
| |
| parse | back to summary |
|---|---|
| public static HourMinute parse(CharSequence text) Obtains an instance of
The string must represent a valid hour-minute.
The format must be
| |
| parse | back to summary |
|---|---|
| public static HourMinute parse(CharSequence text, DateTimeFormatter formatter) Obtains an instance of The text is parsed using the formatter, returning a hour-minute.
| |
| plus | back to summary |
|---|---|
| public HourMinute plus(TemporalAmount amountToAdd) Overrides default java. Returns a copy of this hour-minute with the specified amount added.
This returns a
The calculation is delegated to the amount object by calling
This instance is immutable and unaffected by this method call.
| |
| plus | back to summary |
|---|---|
| public HourMinute plus(long amountToAdd, TemporalUnit unit) Implements java. Returns a copy of this hour-minute with the specified amount added.
This returns a
If the field is a
All other
If the field is not a This instance is immutable and unaffected by this method call.
| |
| plusHours | back to summary |
|---|---|
| public HourMinute plusHours(long hoursToAdd) Returns a copy of this This adds the specified number of hours to this time, returning a new time. The calculation wraps around midnight. This instance is immutable and unaffected by this method call.
| |
| plusMinutes | back to summary |
|---|---|
| public HourMinute plusMinutes(long minutesToAdd) Returns a copy of this This adds the specified number of minutes to this time, returning a new time. The calculation wraps around midnight. This instance is immutable and unaffected by this method call.
| |
| query | back to summary |
|---|---|
| public <R> R query(TemporalQuery<R> query) Overrides default java. Queries this hour-minute using the specified query.
This queries this hour-minute using the specified query strategy object.
The
The result of this method is obtained by invoking the
| |
| range | back to summary |
|---|---|
| public ValueRange range(TemporalField field) Overrides default java. Gets the range of valid values for the specified field. The range object expresses the minimum and maximum valid values for a field. If it is not possible to return the range, because the field is not supported or for some other reason, an exception is thrown.
If the field is a
If the field is not a
| |
| readResolve | back to summary |
|---|---|
| private Object readResolve() Validates the input.
| |
| toLocalTime | back to summary |
|---|---|
| public LocalTime toLocalTime() Returns the equivalent
This returns a
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Outputs this hour-minute as a | |
| until | back to summary |
|---|---|
| public long until(Temporal endExclusive, TemporalUnit unit) Implements java. Calculates the amount of time until another hour-minute in terms of the specified unit.
This calculates the amount of time between two
The calculation is implemented in this method for
If the unit is not a This instance is immutable and unaffected by this method call.
| |
| with | back to summary |
|---|---|
| private HourMinute with(int newYear, int newMinute) Returns a copy of this hour-minute with the new hour and minute, checking to see if a new object is in fact required.
| |
| with | back to summary |
|---|---|
| public HourMinute with(TemporalAdjuster adjuster) Overrides default java. Returns an adjusted copy of this hour-minute.
This returns a
The result of this method is obtained by invoking the
This instance is immutable and unaffected by this method call.
| |
| with | back to summary |
|---|---|
| public HourMinute with(TemporalField field, long newValue) Implements java. Returns a copy of this hour-minute with the specified field set to a new value.
This returns a
If the field is a
In all cases, if the new value is outside the valid range of values for the field
then a
All other
If the field is not a This instance is immutable and unaffected by this method call.
| |
| withHour | back to summary |
|---|---|
| public HourMinute withHour(int hour) Returns a copy of this This instance is immutable and unaffected by this method call.
| |
| withMinute | back to summary |
|---|---|
| public HourMinute withMinute(int minute) Returns a copy of this This instance is immutable and unaffected by this method call.
| |