Java Clock convert to Instant

Description

Java Clock convert to Instant

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

public class Main {
  public static void main(String[] args) {
     Clock clock = Clock.systemDefaultZone();
     System.out.println(clock);//from  ww w .j av a 2  s.  c  o  m
     
     Instant instant = clock.instant();
     System.out.println(instant);
     
  }

}



PreviousNext

Related