Example usage for java.time Clock systemDefaultZone

List of usage examples for java.time Clock systemDefaultZone

Introduction

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

Prototype

public static Clock systemDefaultZone() 

Source Link

Document

Obtains a clock that returns the current instant using the best available system clock, converting to date and time using the default time-zone.

Usage

From source file:Main.java

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

    System.out.println(clock.getZone());
}

From source file:Main.java

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

From source file:Main.java

public static void main(String[] args) {
    Year y = Year.now(Clock.systemDefaultZone());
    System.out.println(y);

}

From source file:Main.java

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

From source file:Main.java

public static void main(String[] args) {
    Instant instant = Instant.now(Clock.systemDefaultZone());
    System.out.println(instant.getEpochSecond());

}

From source file:Main.java

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

    System.out.println(a);
}

From source file:Main.java

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

From source file:Main.java

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

    Instant instant = Instant.now(defaultClock);

    ZonedDateTime zonedDateTime = ZonedDateTime.ofInstant(instant, ZoneId.systemDefault());

    System.out.println(zonedDateTime);
}

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) {
    // Current Time
    Clock clock = Clock.systemUTC();
    System.out.println(Clock.systemDefaultZone());

    LocalDateTime dateAndTime = LocalDateTime.now(clock);
    System.out.println(dateAndTime);
    System.out.println(LocalDateTime.now());

}