Java Reference
In-Depth Information
int nano = time.getNano();
int sec = time.getSecond();
Several comparison methods are also available for use. For example, the
com-
pareTo(LocalTime)
method can be used to compare one
LocalTime
object to
another.
isAfter(LocalTime)
can be used to determine if the time is after anoth-
er, and
isBefore(LocalTime)
is used to specify the opposite. If calculations are
needed, several methods are available, including:
•
minus(long amountToSubtract, TemporalUnit unit)
•
minus(TemporalAmount amount)
•
minusHours(long)
•
minusMinutes(long)
•
minusNanos(long)
•
minusSeconds(long)
•
plus(long amountToAdd, TemporalUnit unit)
•
plus(TemporalAmount amount)
•
plusHours(long)
•
plusMinutes(long)
•
plusNanos(long)
•
plusSeconds(long)
To see all of the methods contained in the
LocalTime
class, see the online docu-
mentation at
http://docs.oracle.com/javase/8/docs/api/java/
4-11. Obtaining and Using the Date and
Time Together
Problem