my container.

Java: timezone shift / Zeit in andere Zeitzone umrechnen

August 1, 2008 · Kommentar schreiben

To calculate a time to another time zone, just

  1. get a timezone object for the new timezone
  2. register the timezone object to a formatter
  3. recalculate the time with the formatter to a string

code sample:

// formatter
DateFormat df = DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.FULL);
// local date
Date now = new Date();
// instanciate timezone
TimeZone timezone = TimeZone.getTimeZone(„Japan“);
// register on formatter
df.setTimeZone(timezone);
// recalculate
System.out.println(„Japan time is:“+df.format(now));

Kategorien: Java
Mit Tag(s) versehen: , , , , ,

0 Antworten bis hierher ↓

  • Bis jetzt noch kein Kommentar ... Bring die Sache ins Rollen, und füll das untere Formular aus.

Kommentar schreiben