Example usage for java.util TimeZone getTimeZone

List of usage examples for java.util TimeZone getTimeZone

Introduction

In this page you can find the example usage for java.util TimeZone getTimeZone.

Prototype

public static TimeZone getTimeZone(ZoneId zoneId) 

Source Link

Document

Gets the TimeZone for the given zoneId .

Usage

From source file:Main.java

public static void main(String[] args) {
    ZoneId defaultZone = TimeZone.getDefault().toZoneId();

    TimeZone tz = TimeZone.getTimeZone(defaultZone);
    System.out.println(tz);/*from   w  ww  .  j  a  v a  2 s . co  m*/
}

From source file:Main.java

public static void main(String args[]) {

    // create default time zone object
    TimeZone timezone = TimeZone.getTimeZone("Europe/Paris");

    // create locale
    Locale locale = new Locale("CHINESE", "CHINA");

    // get display name for specific locale
    String disname = timezone.getDisplayName(locale);

    // checking display name         
    System.out.println("Display name is :" + disname);
}

From source file:Main.java

public static void main(String[] args) {
    Calendar calTokyo = Calendar.getInstance();

    calTokyo.setTimeZone(TimeZone.getTimeZone("Asia/Tokyo"));

    System.out.println(//w w  w.  jav  a2s .  c  o  m
            "Time in Tokyo: " + calTokyo.get(Calendar.HOUR_OF_DAY) + ":" + calTokyo.get(Calendar.MINUTE));
}

From source file:Main.java

public static void main(String[] args) {
    Calendar calParis = Calendar.getInstance();

    calParis.setTimeZone(TimeZone.getTimeZone("Europe/Paris"));
    System.out.println(/*from w  w w  .  j a va2 s.c  o  m*/
            "Time in Paris: " + calParis.get(Calendar.HOUR_OF_DAY) + ":" + calParis.get(Calendar.MINUTE));

}

From source file:MainClass.java

public static void main(String[] a) {
    GregorianCalendar calendar = new GregorianCalendar(TimeZone.getTimeZone("America/Chicago"), Locale.US);
    System.out.println(calendar);
}

From source file:Main.java

public static void main(String[] args) {
    Calendar calNewYork = Calendar.getInstance();

    calNewYork.setTimeZone(TimeZone.getTimeZone("America/New_York"));

    System.out.println("Time in New York: " + calNewYork.get(Calendar.HOUR_OF_DAY) + ":"
            + calNewYork.get(Calendar.MINUTE));

}

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[] args) {

    GregorianCalendar cal = (GregorianCalendar) GregorianCalendar.getInstance();

    // set to another time zone
    cal.setTimeZone(TimeZone.getTimeZone("GMT"));
    System.out.println("New Time Zone:" + cal.getTimeZone().getDisplayName());

}