LocalTime until(Temporal endExclusive, TemporalUnit unit) example

Description

LocalTime until(Temporal endExclusive, TemporalUnit unit) calculates the amount of time until another time in terms of the specified unit.

Syntax

until has the following syntax.


public long until(Temporal endExclusive,  TemporalUnit unit)

Example

The following example shows how to use until.


import java.time.LocalTime;
import java.time.temporal.ChronoUnit;
//from  w  w w  .  j  a  v a 2 s .  c om
public class Main {
  public static void main(String[] args) {
    LocalTime l = LocalTime.now();
    long s = l.until(LocalTime.NOON,ChronoUnit.HOURS);
    System.out.println(s);
  }
}

The code above generates the following result.





















Home »
  Java Date Time »
    java.time Reference »




Clock
DayOfWeek
Duration
Instant
LocalDate
LocalDateTime
LocalTime
Month
MonthDay
OffsetDateTime
OffsetTime
Period
Year
YearMonth
ZonedDateTime
ZoneId
ZoneOffset