Java Date Time Java Java API
java.time.Instant
public static Instant now()
Obtains the current instant from the system clock.
public static Instant now(Clock clock)
Obtains the current instant from the specified clock.
package com.logicbig.example.instant;import java.time.Instant;public class NowExample { public static void main(String... args) { Instant i = Instant.now(); System.out.println(i); }}
2017-05-01T20:57:32.709Z
package com.logicbig.example.instant;import java.time.Clock;import java.time.Instant;import java.time.ZoneId;public class NowExample2 { public static void main(String... args) { Instant i = Instant.now(Clock.system(ZoneId.of("America/Chicago"))); System.out.println(i); }}
2017-05-01T20:57:34.818Z