Java Date Time Java Java API
java.time.LocalTime
public static LocalTime now()
Returns the current local time instance from the system clock in the default time-zone.
public static LocalTime now(ZoneId zone)
Returns the current local time instance from the system clock, adjusting fields values to the specified time-zone.
public static LocalTime now(Clock clock)
Returns the current local time instance from the provided Clock.
package com.logicbig.example.localtime;import java.time.LocalTime;public class NowExample { public static void main (String... args) { LocalTime t = LocalTime.now(); System.out.println(t); }}
16:25:07.969
package com.logicbig.example.localtime;import java.time.LocalTime;import java.time.ZoneId;public class NowExample2 { public static void main (String... args) { LocalTime t = LocalTime.now(ZoneId.of("Japan")); System.out.println(t); }}
06:25:10.211
package com.logicbig.example.localtime;import java.time.Clock;import java.time.LocalTime;public class NowExample3 { public static void main (String... args) { LocalTime t = LocalTime.now(Clock.systemDefaultZone()); System.out.println(t); }}
16:25:12.333