Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.time.Clock;
import java.time.Instant;
import java.time.LocalDate;
import java.time.ZonedDateTime;

public class Main {
    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);
    }
}