Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.time.Instant;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;

public class Main {
    public static void main(String[] argv) {

        Instant instantFromDate = new Date().toInstant();

        Instant instantFromCalendar = Calendar.getInstance().toInstant();
        System.out.println(instantFromCalendar);

        ZoneId zoneId = java.util.TimeZone.getDefault().toZoneId();
        System.out.println(zoneId);

        ZonedDateTime zonedDateTimeFromGregorianCalendar = new GregorianCalendar().toZonedDateTime();

        System.out.println(zonedDateTimeFromGregorianCalendar);
    }
}