Java Date Time Java Java API
java.time.LocalDateTime
public static LocalDateTime now()
Returns the current local date time instance from the system clock in the default time-zone.
public static LocalDateTime now(ZoneId zone)
Returns the current local date time instance from the system clock, adjusting fields values to the specified time-zone.
public static LocalDateTime now(Clock clock)
Returns the current local date instance from the provided Clock.
package com.logicbig.example.localdatetime;import java.time.LocalDateTime;public class NowExample { public static void main (String... args) { LocalDateTime d = LocalDateTime.now(); System.out.println(d); }}
2017-05-01T16:27:39.195
package com.logicbig.example.localdatetime;import java.time.LocalDateTime;import java.time.ZoneId;public class NowExample2 { public static void main (String... args) { LocalDateTime d = LocalDateTime.now( ZoneId.of("Pacific/Kiritimati")); System.out.println(d); }}
2017-05-02T11:27:41.260
package com.logicbig.example.localdatetime;import java.time.Clock;import java.time.LocalDateTime;import java.time.ZoneId;public class NowExample3 { public static void main (String... args) { LocalDateTime d = LocalDateTime.now( Clock.tickSeconds(ZoneId.of("Japan"))); System.out.println(d); }}
2017-05-02T06:27:43