List of usage examples for java.util GregorianCalendar GregorianCalendar
public GregorianCalendar(Locale aLocale)
GregorianCalendar
based on the current time in the default time zone with the given locale. From source file:MainClass.java
public static void main(String[] a) { GregorianCalendar calendar = new GregorianCalendar(Locale.UK); }
From source file:MainClass.java
public static void main(String[] a) { GregorianCalendar calendar = new GregorianCalendar(TimeZone.getTimeZone("America/Chicago")); System.out.println(calendar); }
From source file:Main.java
public static void main(String[] args) { GregorianCalendar cal = new GregorianCalendar(Locale.ENGLISH); System.out.println(cal.getTime()); }
From source file:Main.java
public static void main(String[] args) { GregorianCalendar cal = new GregorianCalendar(TimeZone.getDefault()); System.out.println(cal.getTime()); }
From source file:Main.java
public static void main(String[] argv) throws Exception { Calendar japanCal = new GregorianCalendar(TimeZone.getTimeZone("Japan")); japanCal.set(Calendar.HOUR_OF_DAY, 10); // 0..23 japanCal.set(Calendar.MINUTE, 0); japanCal.set(Calendar.SECOND, 0); }
From source file:Main.java
public static void main(String[] argv) throws Exception { Calendar japanCal = new GregorianCalendar(TimeZone.getTimeZone("Japan")); japanCal.set(Calendar.HOUR_OF_DAY, 10); // 0..23 japanCal.set(Calendar.MINUTE, 0); japanCal.set(Calendar.SECOND, 0); Calendar local = new GregorianCalendar(); local.setTimeInMillis(japanCal.getTimeInMillis()); }
From source file:Main.java
public static void main(String[] argv) throws Exception { Calendar japanCal = new GregorianCalendar(TimeZone.getTimeZone("Japan")); japanCal.set(Calendar.HOUR_OF_DAY, 10); // 0..23 japanCal.set(Calendar.MINUTE, 0); japanCal.set(Calendar.SECOND, 0); Calendar local = new GregorianCalendar(); local.setTimeInMillis(japanCal.getTimeInMillis()); int hour = local.get(Calendar.HOUR); // 5 int minutes = local.get(Calendar.MINUTE); // 0 int seconds = local.get(Calendar.SECOND); // 0 boolean am = local.get(Calendar.AM_PM) == Calendar.AM; // false }
From source file:Main.java
public static void main(String[] argv) throws Exception { Calendar local = Calendar.getInstance(); Calendar japanCal = new GregorianCalendar(TimeZone.getTimeZone("Japan")); japanCal.setTimeInMillis(local.getTimeInMillis()); }
From source file:Main.java
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 }
From source file:Main.java
public static void main(String[] argv) throws Exception { // Get the current time in Hong Kong Calendar cal = new GregorianCalendar(TimeZone.getTimeZone("Hongkong")); int hour12 = cal.get(Calendar.HOUR); // 0..11 int minutes = cal.get(Calendar.MINUTE); // 0..59 int seconds = cal.get(Calendar.SECOND); // 0..59 boolean am = cal.get(Calendar.AM_PM) == Calendar.AM; // Get the current hour-of-day at GMT cal.setTimeZone(TimeZone.getTimeZone("GMT")); int hour24 = cal.get(Calendar.HOUR_OF_DAY); // 0..23 // Get the current local hour-of-day cal.setTimeZone(TimeZone.getDefault()); hour24 = cal.get(Calendar.HOUR_OF_DAY); // 0..23 }