Close

Java Date Time - Clock.instant() Examples

Java Date Time Java Java API 


Class:

java.time.Clock

java.lang.Objectjava.lang.Objectjava.time.Clockjava.time.ClockLogicBig

Method:

public abstract Instant instant()

Returns the current instant of this clock.


Examples


package com.logicbig.example.clock;

import java.time.Clock;
import java.time.Instant;

public class InstantExample {

public static void main(String... args) {
Clock c = Clock.systemDefaultZone();
System.out.println(c);

Instant instant = c.instant();
System.out.println(instant);
}
}

Output

SystemClock[America/Chicago]
2017-05-01T20:48:12.861Z




See Also