Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.TimeZone;

public class Main {
    public static void main(String[] args) {
        Date d = new Date();
        System.out.println(d);

        DateFormat df = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
        df.setTimeZone(TimeZone.getTimeZone("Australia/Sydney"));
        System.out.println(df.format(d));
        df.setTimeZone(TimeZone.getTimeZone("Europe/London"));
        System.out.println(df.format(d));
    }
}