LocalTime now(ZoneId zone) example

Description

LocalTime now(ZoneId zone) gets the current time from the system clock in the specified time-zone.

Syntax

now has the following syntax.


public static LocalTime now(ZoneId zone)

Example

The following example shows how to use now.


import java.time.LocalTime;
import java.time.ZoneId;
/*www. j av a2  s . co m*/
public class Main {
  public static void main(String[] args) {
    LocalTime l = LocalTime.now(ZoneId.systemDefault());
    
    System.out.println(l);
  }
}

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