Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.util.Calendar;
import java.util.GregorianCalendar;
import java.util.TimeZone;

public class Main {
    public static void main(String[] argv) throws Exception {
        Calendar local = Calendar.getInstance();
        Calendar japanCal = new GregorianCalendar(TimeZone.getTimeZone("Japan"));
        japanCal.setTimeInMillis(local.getTimeInMillis());

        int hour = japanCal.get(Calendar.HOUR); // 3
        int minutes = japanCal.get(Calendar.MINUTE); // 0
        int seconds = japanCal.get(Calendar.SECOND); // 0
        boolean am = japanCal.get(Calendar.AM_PM) == Calendar.AM; // true
    }
}