public final class LocalTime extends java.lang.Object implements Temporal, Temporal.WithAdjuster, java.lang.Comparable<LocalTime>, java.io.Serializable
10:15:30
.
LocalTime
is an immutable date-time object that represents a time, often
viewed as hour-minute-second.
This class stores all time fields, to a precision of nanoseconds.
It does not store or represent a date or time-zone.
For example, the value "13:45.30.123456789" can be stored in a LocalTime
.
Temporal.MinusAdjuster, Temporal.PlusAdjuster, Temporal.WithAdjuster
TemporalAccessor.Query<R>
Modifier and Type | Field and Description |
---|---|
static LocalTime |
MAX_TIME
Constant for the local time just before midnight, 23:59:59.999999999.
|
static LocalTime |
MIDNIGHT
Constant for the local time of midnight, 00:00.
|
static LocalTime |
MIN_TIME
Constant for the local time of midnight, 00:00.
|
static LocalTime |
NOON
Constant for the local time of noon, 12:00.
|
Modifier and Type | Method and Description |
---|---|
LocalDateTime |
atDate(LocalDate date)
Returns a local date-time formed from this time at the specified date.
|
OffsetTime |
atOffset(ZoneOffset offset)
Returns an offset time formed from this time and the specified offset.
|
int |
compareTo(LocalTime other)
Compares this
LocalTime to another time. |
Temporal |
doWithAdjustment(Temporal temporal)
Implementation of the strategy to make an adjustment to the specified temporal object.
|
boolean |
equals(java.lang.Object obj)
Checks if this time is equal to another time.
|
static LocalTime |
from(TemporalAccessor temporal)
Obtains an instance of
LocalTime from a temporal object. |
int |
get(TemporalField field)
Gets the value of the specified field as an
int . |
int |
getHour()
Gets the hour-of-day field.
|
long |
getLong(TemporalField field)
Gets the value of the specified field as a
Long . |
int |
getMinute()
Gets the minute-of-hour field.
|
int |
getNano()
Gets the nano-of-second field.
|
int |
getSecond()
Gets the second-of-minute field.
|
int |
hashCode()
A hash code for this time.
|
boolean |
isAfter(LocalTime other)
Checks if this
LocalTime is after the specified time. |
boolean |
isBefore(LocalTime other)
Checks if this
LocalTime is before the specified time. |
boolean |
isSupported(TemporalField field)
Checks if the specified field is supported.
|
LocalTime |
minus(long amountToSubtract,
TemporalUnit unit)
Returns a copy of this time with the specified period subtracted.
|
LocalTime |
minus(Temporal.MinusAdjuster adjuster)
Returns a copy of this time with the specified period subtracted.
|
LocalTime |
minusHours(long hoursToSubtract)
Returns a copy of this
LocalTime with the specified period in hours subtracted. |
LocalTime |
minusMinutes(long minutesToSubtract)
Returns a copy of this
LocalTime with the specified period in minutes subtracted. |
LocalTime |
minusNanos(long nanosToSubtract)
Returns a copy of this
LocalTime with the specified period in nanoseconds subtracted. |
LocalTime |
minusSeconds(long secondsToSubtract)
Returns a copy of this
LocalTime with the specified period in seconds subtracted. |
static LocalTime |
now()
Obtains the current time from the system clock in the default time-zone.
|
static LocalTime |
now(Clock clock)
Obtains the current time from the specified clock.
|
static LocalTime |
now(ZoneId zone)
Obtains the current time from the system clock in the specified time-zone.
|
static LocalTime |
of(int hour,
int minute)
Obtains an instance of
LocalTime from an hour and minute. |
static LocalTime |
of(int hour,
int minute,
int second)
Obtains an instance of
LocalTime from an hour, minute and second. |
static LocalTime |
of(int hour,
int minute,
int second,
int nanoOfSecond)
Obtains an instance of
LocalTime from an hour, minute, second and nanosecond. |
static LocalTime |
ofNanoOfDay(long nanoOfDay)
Obtains an instance of
LocalTime from a nanos-of-day value. |
static LocalTime |
ofSecondOfDay(long secondOfDay)
Obtains an instance of
LocalTime from a second-of-day value. |
static LocalTime |
ofSecondOfDay(long secondOfDay,
int nanoOfSecond)
Obtains an instance of
LocalTime from a second-of-day value, with
associated nanos of second. |
static LocalTime |
parse(java.lang.CharSequence text)
Obtains an instance of
LocalTime from a text string such as 10:15 . |
static LocalTime |
parse(java.lang.CharSequence text,
DateTimeFormatter formatter)
Obtains an instance of
LocalTime from a text string using a specific formatter. |
long |
periodUntil(Temporal endDateTime,
TemporalUnit unit)
Calculates the period from this date-time until the given date-time in the specified unit.
|
LocalTime |
plus(long amountToAdd,
TemporalUnit unit)
Returns a copy of this time with the specified period added.
|
LocalTime |
plus(Temporal.PlusAdjuster adjuster)
Returns a copy of this date with the specified period added.
|
LocalTime |
plusHours(long hoursToAdd)
Returns a copy of this
LocalTime with the specified period in hours added. |
LocalTime |
plusMinutes(long minutesToAdd)
Returns a copy of this
LocalTime with the specified period in minutes added. |
LocalTime |
plusNanos(long nanosToAdd)
Returns a copy of this
LocalTime with the specified period in nanoseconds added. |
LocalTime |
plusSeconds(long secondstoAdd)
Returns a copy of this
LocalTime with the specified period in seconds added. |
<R> R |
query(TemporalAccessor.Query<R> query)
Queries this date-time.
|
ValueRange |
range(TemporalField field)
Gets the range of valid values for the specified field.
|
long |
toNanoOfDay()
Extracts the time as nanos of day,
from
0 to 24 * 60 * 60 * 1,000,000,000 - 1 . |
int |
toSecondOfDay()
Extracts the time as seconds of day,
from
0 to 24 * 60 * 60 - 1 . |
java.lang.String |
toString()
Outputs this time as a
String , such as 10:15 . |
java.lang.String |
toString(DateTimeFormatter formatter)
Outputs this time as a
String using the formatter. |
LocalTime |
truncatedTo(TemporalUnit unit)
Returns a copy of this
LocalTime with the time truncated. |
LocalTime |
with(Temporal.WithAdjuster adjuster)
Returns an adjusted time based on this time.
|
LocalTime |
with(TemporalField field,
long newValue)
Returns a copy of this time with the specified field altered.
|
LocalTime |
withHour(int hour)
Returns a copy of this
LocalTime with the hour-of-day value altered. |
LocalTime |
withMinute(int minute)
Returns a copy of this
LocalTime with the minute-of-hour value altered. |
LocalTime |
withNano(int nanoOfSecond)
Returns a copy of this
LocalTime with the nano-of-second value altered. |
LocalTime |
withSecond(int second)
Returns a copy of this
LocalTime with the second-of-minute value altered. |
public static final LocalTime MIN_TIME
public static final LocalTime MAX_TIME
public static final LocalTime MIDNIGHT
public static final LocalTime NOON
public static LocalTime now()
This will query the system clock
in the default
time-zone to obtain the current time.
Using this method will prevent the ability to use an alternate clock for testing because the clock is hard-coded.
public static LocalTime now(ZoneId zone)
This will query the system clock
to obtain the current time.
Specifying the time-zone avoids dependence on the default time-zone.
Using this method will prevent the ability to use an alternate clock for testing because the clock is hard-coded.
public static LocalTime now(Clock clock)
This will query the specified clock to obtain the current time.
Using this method allows the use of an alternate clock for testing.
The alternate clock may be introduced using dependency injection
.
clock
- the clock to use, not nullpublic static LocalTime of(int hour, int minute)
LocalTime
from an hour and minute.
The second and nanosecond fields will be set to zero by this factory method.
This factory may return a cached value, but applications must not rely on this.
hour
- the hour-of-day to represent, from 0 to 23minute
- the minute-of-hour to represent, from 0 to 59DateTimeException
- if the value of any field is out of rangepublic static LocalTime of(int hour, int minute, int second)
LocalTime
from an hour, minute and second.
The nanosecond field will be set to zero by this factory method.
This factory may return a cached value, but applications must not rely on this.
hour
- the hour-of-day to represent, from 0 to 23minute
- the minute-of-hour to represent, from 0 to 59second
- the second-of-minute to represent, from 0 to 59DateTimeException
- if the value of any field is out of rangepublic static LocalTime of(int hour, int minute, int second, int nanoOfSecond)
LocalTime
from an hour, minute, second and nanosecond.
This factory may return a cached value, but applications must not rely on this.
hour
- the hour-of-day to represent, from 0 to 23minute
- the minute-of-hour to represent, from 0 to 59second
- the second-of-minute to represent, from 0 to 59nanoOfSecond
- the nano-of-second to represent, from 0 to 999,999,999DateTimeException
- if the value of any field is out of rangepublic static LocalTime ofSecondOfDay(long secondOfDay)
LocalTime
from a second-of-day value.
This factory may return a cached value, but applications must not rely on this.
secondOfDay
- the second-of-day, from 0
to 24 * 60 * 60 - 1
DateTimeException
- if the second-of-day value is invalidpublic static LocalTime ofSecondOfDay(long secondOfDay, int nanoOfSecond)
LocalTime
from a second-of-day value, with
associated nanos of second.
This factory may return a cached value, but applications must not rely on this.
secondOfDay
- the second-of-day, from 0
to 24 * 60 * 60 - 1
nanoOfSecond
- the nano-of-second, from 0 to 999,999,999DateTimeException
- if the either input value is invalidpublic static LocalTime ofNanoOfDay(long nanoOfDay)
LocalTime
from a nanos-of-day value.
This factory may return a cached value, but applications must not rely on this.
nanoOfDay
- the nano of day, from 0
to 24 * 60 * 60 * 1,000,000,000 - 1
DateTimeException
- if the nanos of day value is invalidpublic static LocalTime from(TemporalAccessor temporal)
LocalTime
from a temporal object.
A TemporalAccessor
represents some form of date and time information.
This factory converts the arbitrary temporal object to an instance of LocalTime
.
The conversion extracts the nano-of-day
field.
temporal
- the temporal object to convert, not nullDateTimeException
- if unable to convert to a LocalTime
public static LocalTime parse(java.lang.CharSequence text)
LocalTime
from a text string such as 10:15
.
The string must represent a valid time and is parsed using
DateTimeFormatters.isoLocalTime()
.
text
- the text to parse such as "10:15:30", not nullDateTimeParseException
- if the text cannot be parsedpublic static LocalTime parse(java.lang.CharSequence text, DateTimeFormatter formatter)
LocalTime
from a text string using a specific formatter.
The text is parsed using the formatter, returning a time.
text
- the text to parse, not nullformatter
- the formatter to use, not nullDateTimeParseException
- if the text cannot be parsedpublic boolean isSupported(TemporalField field)
TemporalAccessor
This checks if the date-time can be queried for the specified field.
If false, then calling the range
and get
methods will throw an exception.
ChronoField
before
delegating on to the doRange method
on the specified field.isSupported
in interface TemporalAccessor
field
- the field to check, null returns falsepublic ValueRange range(TemporalField field)
TemporalAccessor
All fields can be expressed as a long
integer.
This method returns an object that describes the valid range for that value.
If the date-time cannot return the range, because the field is unsupported or for
some other reason, an exception will be thrown.
Note that the result only describes the minimum and maximum valid values and it is important not to read too much into them. For example, there could be values within the range that are invalid for the field.
ChronoField
before
delegating on to the doRange method
on the specified field.
This default implementation checks the field to determine if it is a ChronoField
.
If the field is, then if it is supported
the
TemporalField.range()
method is used, otherwise an exception is thrown.
If it is not a ChronoField
then TemporalField.doRange(TemporalAccessor)
is called.
range
in interface TemporalAccessor
field
- the field to get, not nullpublic int get(TemporalField field)
TemporalAccessor
int
.
This queries the date-time for the value for the specified field. The returned value will always be within the valid range of values for the field. If the date-time cannot return the value, because the field is unsupported or for some other reason, an exception will be thrown.
ChronoField
before
delegating on to the doGet method
on the specified field.
This default implementation uses TemporalAccessor.getLong(TemporalField)
to find the value and
TemporalAccessor.range(TemporalField)
to validate it.
get
in interface TemporalAccessor
field
- the field to get, not nullpublic long getLong(TemporalField field)
TemporalAccessor
Long
.
This queries the date-time for the value for the specified field. The returned value may be outside the valid range of values for the field. If the date-time cannot return the value, because the field is unsupported or for some other reason, an exception will be thrown.
ChronoField
before
delegating on to the doGet method
on the specified field.getLong
in interface TemporalAccessor
field
- the field to get, not nullpublic int getHour()
public int getMinute()
public int getSecond()
public int getNano()
public LocalTime with(Temporal.WithAdjuster adjuster)
This adjusts the time according to the rules of the specified adjuster. A simple adjuster might simply set the one of the fields, such as the hour field. A more complex adjuster might set the time to the last hour of the day. The adjuster is responsible for handling special cases, such as the varying lengths of month and leap years.
For example, were there to be a class AmPm
implementing the adjuster
interface then this method could be used to change the AM/PM value.
This instance is immutable and unaffected by this method call.
with
in interface Temporal
adjuster
- the adjuster to use, not nullLocalTime
based on this time with the adjustment made, not nullDateTimeException
- if the adjustment cannot be madepublic LocalTime with(TemporalField field, long newValue)
This method returns a new time based on this time with a new value for the specified field. This can be used to change any field, for example to set the hour-of-day.
This instance is immutable and unaffected by this method call.
with
in interface Temporal
field
- the field to set in the result, not nullnewValue
- the new value of the field in the resultLocalTime
based on this time with the specified field set, not nullDateTimeException
- if the value is invalidpublic LocalTime withHour(int hour)
LocalTime
with the hour-of-day value altered.
This instance is immutable and unaffected by this method call.
hour
- the hour-of-day to set in the result, from 0 to 23LocalTime
based on this time with the requested hour, not nullDateTimeException
- if the hour value is invalidpublic LocalTime withMinute(int minute)
LocalTime
with the minute-of-hour value altered.
This instance is immutable and unaffected by this method call.
minute
- the minute-of-hour to set in the result, from 0 to 59LocalTime
based on this time with the requested minute, not nullDateTimeException
- if the minute value is invalidpublic LocalTime withSecond(int second)
LocalTime
with the second-of-minute value altered.
This instance is immutable and unaffected by this method call.
second
- the second-of-minute to set in the result, from 0 to 59LocalTime
based on this time with the requested second, not nullDateTimeException
- if the second value is invalidpublic LocalTime withNano(int nanoOfSecond)
LocalTime
with the nano-of-second value altered.
This instance is immutable and unaffected by this method call.
nanoOfSecond
- the nano-of-second to set in the result, from 0 to 999,999,999LocalTime
based on this time with the requested nanosecond, not nullDateTimeException
- if the nanos value is invalidpublic LocalTime truncatedTo(TemporalUnit unit)
LocalTime
with the time truncated.
Truncating the time returns a copy of the original time with fields
smaller than the specified unit set to zero.
For example, truncating with the minutes
unit
will set the second-of-minute and nano-of-second field to zero.
Not all units are accepted. The days
unit and time
units with an exact duration can be used, other units throw an exception.
This instance is immutable and unaffected by this method call.
unit
- the unit to truncate to, not nullLocalTime
based on this time with the time truncated, not nullDateTimeException
- if unable to truncatepublic LocalTime plus(Temporal.PlusAdjuster adjuster)
This method returns a new time based on this time with the specified period added.
The adjuster is typically Period
but may be any other type implementing
the Temporal.PlusAdjuster
interface.
The calculation is delegated to the specified adjuster, which typically calls
back to plus(long, javax.time.temporal.TemporalUnit)
.
This instance is immutable and unaffected by this method call.
plus
in interface Temporal
adjuster
- the adjuster to use, not nullLocalTime
based on this time with the addition made, not nullDateTimeException
- if the addition cannot be madejava.lang.ArithmeticException
- if numeric overflow occurspublic LocalTime plus(long amountToAdd, TemporalUnit unit)
This method returns a new time based on this time with the specified period added. This can be used to add any period that is defined by a unit, for example to add hours, minutes or seconds. The unit is responsible for the details of the calculation, including the resolution of any edge cases in the calculation.
This instance is immutable and unaffected by this method call.
plus
in interface Temporal
amountToAdd
- the amount of the unit to add to the result, may be negativeunit
- the unit of the period to add, not nullLocalTime
based on this time with the specified period added, not nullDateTimeException
- if the unit cannot be added to this typepublic LocalTime plusHours(long hoursToAdd)
LocalTime
with the specified period in hours added.
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.
hoursToAdd
- the hours to add, may be negativeLocalTime
based on this time with the hours added, not nullpublic LocalTime plusMinutes(long minutesToAdd)
LocalTime
with the specified period in minutes added.
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.
minutesToAdd
- the minutes to add, may be negativeLocalTime
based on this time with the minutes added, not nullpublic LocalTime plusSeconds(long secondstoAdd)
LocalTime
with the specified period in seconds added.
This adds the specified number of seconds to this time, returning a new time. The calculation wraps around midnight.
This instance is immutable and unaffected by this method call.
secondstoAdd
- the seconds to add, may be negativeLocalTime
based on this time with the seconds added, not nullpublic LocalTime plusNanos(long nanosToAdd)
LocalTime
with the specified period in nanoseconds added.
This adds the specified number of nanoseconds to this time, returning a new time. The calculation wraps around midnight.
This instance is immutable and unaffected by this method call.
nanosToAdd
- the nanos to add, may be negativeLocalTime
based on this time with the nanoseconds added, not nullpublic LocalTime minus(Temporal.MinusAdjuster adjuster)
This method returns a new time based on this time with the specified period subtracted.
The adjuster is typically Period
but may be any other type implementing
the Temporal.MinusAdjuster
interface.
The calculation is delegated to the specified adjuster, which typically calls
back to minus(long, javax.time.temporal.TemporalUnit)
.
This instance is immutable and unaffected by this method call.
minus
in interface Temporal
adjuster
- the adjuster to use, not nullLocalTime
based on this time with the subtraction made, not nullDateTimeException
- if the subtraction cannot be madejava.lang.ArithmeticException
- if numeric overflow occurspublic LocalTime minus(long amountToSubtract, TemporalUnit unit)
This method returns a new time based on this time with the specified period subtracted. This can be used to subtract any period that is defined by a unit, for example to subtract hours, minutes or seconds. The unit is responsible for the details of the calculation, including the resolution of any edge cases in the calculation.
This instance is immutable and unaffected by this method call.
minus
in interface Temporal
amountToSubtract
- the amount of the unit to subtract from the result, may be negativeunit
- the unit of the period to subtract, not nullLocalTime
based on this time with the specified period subtracted, not nullDateTimeException
- if the unit cannot be added to this typepublic LocalTime minusHours(long hoursToSubtract)
LocalTime
with the specified period in hours subtracted.
This subtracts the specified number of hours from this time, returning a new time. The calculation wraps around midnight.
This instance is immutable and unaffected by this method call.
hoursToSubtract
- the hours to subtract, may be negativeLocalTime
based on this time with the hours subtracted, not nullpublic LocalTime minusMinutes(long minutesToSubtract)
LocalTime
with the specified period in minutes subtracted.
This subtracts the specified number of minutes from this time, returning a new time. The calculation wraps around midnight.
This instance is immutable and unaffected by this method call.
minutesToSubtract
- the minutes to subtract, may be negativeLocalTime
based on this time with the minutes subtracted, not nullpublic LocalTime minusSeconds(long secondsToSubtract)
LocalTime
with the specified period in seconds subtracted.
This subtracts the specified number of seconds from this time, returning a new time. The calculation wraps around midnight.
This instance is immutable and unaffected by this method call.
secondsToSubtract
- the seconds to subtract, may be negativeLocalTime
based on this time with the seconds subtracted, not nullpublic LocalTime minusNanos(long nanosToSubtract)
LocalTime
with the specified period in nanoseconds subtracted.
This subtracts the specified number of nanoseconds from this time, returning a new time. The calculation wraps around midnight.
This instance is immutable and unaffected by this method call.
nanosToSubtract
- the nanos to subtract, may be negativeLocalTime
based on this time with the nanoseconds subtracted, not nullpublic LocalDateTime atDate(LocalDate date)
This combines this time with the specified date to form a LocalDateTime
.
All possible combinations of date and time are valid.
This instance is immutable and unaffected by this method call.
date
- the date to combine with, not nullpublic OffsetTime atOffset(ZoneOffset offset)
This combines this time with the specified offset to form an OffsetTime
.
All possible combinations of time and offset are valid.
This instance is immutable and unaffected by this method call.
offset
- the offset to combine with, not nullpublic Temporal doWithAdjustment(Temporal temporal)
Temporal.WithAdjuster
This method is not intended to be called by application code directly.
Instead, the Temporal.with(WithAdjuster)
method should be used:
dateTime = dateTime.with(adjuster);
Implementations must use the methods on Temporal
to make the adjustment.
The returned object must have the same observable type as the input object
The target object must not be altered by this method. Instead, an adjusted copy of the original must be returned. This provides equivalent, safe behavior for immutable and mutable implementations.
This interface can be used by calendar systems other than ISO. Implementations may choose to document compatibility with other calendar systems, or validate for it by querying the chronology from the input object.
doWithAdjustment
in interface Temporal.WithAdjuster
temporal
- the temporal object to adjust, not nullpublic long periodUntil(Temporal endDateTime, TemporalUnit unit)
Temporal
This is used to calculate the period between two date-times.
This method operates in association with TemporalUnit.between(R, R)
.
That method returns an object which can be used directly in addition/subtraction
whereas this method returns the amount directly:
long period = start.periodUntil(end, MONTHS); // this method long period = MONTHS.between(start, end).getAmount(); // same as above dateTime.plus(MONTHS.between(start, end)); // directly add
periodUntil
in interface Temporal
endDateTime
- the end date-time, of the same type as this object, not nullunit
- the unit to measure the period in, not nullpublic <R> R query(TemporalAccessor.Query<R> query)
TemporalAccessor
This queries this date-time using the specified query strategy object.
The Query
interface defines a number of useful queries.
Other queries may be defined by applications.
TemporalAccessor
that cannot be returned as a long
using a field.
In use, there is no difference between the two purposes. However, there is a difference in implementation. It is the responsibility of implementations of this method to return a value for the three special constants if applicable.
The three special predefined constants are TemporalAccessor.Query.ZONE_ID
,
TemporalAccessor.Query.CHRONO
and TemporalAccessor.Query.TIME_PRECISION
.
Future JDKs are permitted to add further special constants.
The standard implementation of this method will be similar to the following:
public <R> R query(Query<R> type) { // only include an if statement if the implementation can return it if (query == Query.ZONE_ID) return ... // the ZoneId if (query == Query.CHRONO) return ... // the Chrono if (query == Query.TIME_PRECISION) return ... // the precision // call default method return super.query(query); }If the implementation class has no zone, chronology or precision, then the class can rely totally on the default implementation.
This default implementation invokes TemporalAccessor.Query.doQuery(TemporalAccessor)
.
query
in interface TemporalAccessor
R
- the type of the resultquery
- the query to invoke, not nullpublic int toSecondOfDay()
0
to 24 * 60 * 60 - 1
.public long toNanoOfDay()
0
to 24 * 60 * 60 * 1,000,000,000 - 1
.public int compareTo(LocalTime other)
LocalTime
to another time.
The comparison is based on the time-line position of the local times within a day.
It is "consistent with equals", as defined by Comparable
.
compareTo
in interface java.lang.Comparable<LocalTime>
other
- the other time to compare to, not nulljava.lang.NullPointerException
- if other
is nullpublic boolean isAfter(LocalTime other)
LocalTime
is after the specified time.
The comparison is based on the time-line position of the time within a day.
other
- the other time to compare to, not nulljava.lang.NullPointerException
- if other
is nullpublic boolean isBefore(LocalTime other)
LocalTime
is before the specified time.
The comparison is based on the time-line position of the time within a day.
other
- the other time to compare to, not nulljava.lang.NullPointerException
- if other
is nullpublic boolean equals(java.lang.Object obj)
The comparison is based on the time-line position of the time within a day.
Only objects of type LocalTime
are compared, other types return false.
To compare the date of two TemporalAccessor
instances, use
ChronoField.NANO_OF_DAY
as a comparator.
equals
in class java.lang.Object
obj
- the object to check, null returns falseObject.hashCode()
,
HashMap
public int hashCode()
hashCode
in class java.lang.Object
Object.equals(java.lang.Object)
,
System.identityHashCode(java.lang.Object)
public java.lang.String toString()
String
, such as 10:15
.
The output will be one of the following ISO-8601 formats:
HH:mm
HH:mm:ss
HH:mm:ss.SSS
HH:mm:ss.SSSSSS
HH:mm:ss.SSSSSSSSS
The format used will be the shortest that outputs the full value of the time where the omitted parts are implied to be zero.
toString
in class java.lang.Object
public java.lang.String toString(DateTimeFormatter formatter)
String
using the formatter.formatter
- the formatter to use, not nullDateTimeException
- if an error occurs during printing