Example usage for java.time Clock instant

List of usage examples for java.time Clock instant

Introduction

In this page you can find the example usage for java.time Clock instant.

Prototype

public abstract Instant instant();

Source Link

Document

Gets the current instant of the clock.

Usage

From source file:Main.java

public static void main(String[] args) {
    Clock clock = Clock.systemUTC();
    System.out.println(clock.instant());
}

From source file:Main.java

public static void main(String[] args) {
    Clock clock = Clock.tickMinutes(ZoneId.systemDefault());
    Duration duration = Duration.ofHours(3);
    Clock newClock = Clock.tick(clock, duration);

    System.out.println(newClock.instant());
}

From source file:Main.java

public static void main(String[] args) {
    Clock clock = Clock.systemUTC();
    Duration duration = Duration.ofHours(3);
    Clock newClock = Clock.offset(clock, duration);

    System.out.println(newClock.instant());
}

From source file:Main.java

public static void main(String[] args) {
    Clock clock = Clock.systemDefaultZone();

    Instant instant1 = clock.instant();
    System.out.println(instant1);

    Instant instant2 = Instant.now(clock);
    System.out.println(instant2);

    LocalDate localDate = LocalDate.now(clock);
    System.out.println(localDate);

    ZonedDateTime zoneDateTime = ZonedDateTime.now(clock);
    System.out.println(zoneDateTime);
}

From source file:Main.java

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

From source file:Main.java

public static void main(String[] args) {
    Instant instant = Instant.now();
    Clock newClock = Clock.fixed(instant, ZoneId.systemDefault());

    System.out.println(newClock.instant());
}

From source file:Main.java

public static void main(String[] args) {
    Clock clock = Clock.systemDefaultZone();
    System.out.println(clock);// w w  w.  j  a v  a  2s .co  m
    System.out.println(clock.instant());
}

From source file:Main.java

public static void main(String[] args) {
    Clock clock = Clock.system(ZoneId.systemDefault());
    System.out.println(clock);/*from w ww .j  a va2s.com*/
    System.out.println(clock.instant());
}

From source file:Main.java

public static void main(String[] args) {
    Clock clock = Clock.tickSeconds(ZoneId.systemDefault());
    System.out.println(clock);/*from ww  w.  java 2s  .  co  m*/
    System.out.println(clock.instant());
}

From source file:Main.java

public static void main(String[] args) {
    Clock clock = Clock.tickMinutes(ZoneId.systemDefault());
    System.out.println(clock);/*from  w  w w . j a  v  a 2  s  . c  o  m*/
    System.out.println(clock.instant());
}