Simpledateformat Foo = New Simpledateformat ("yyyy-mm-dd hh: mm: SS" ); System. Out. println ( "Foo:" + Foo. Format ( New Date (); Calendar GC = Gregoriancalendar. getinstance (); system. Out. println ( "GC. gettime ():" + GC. gettime (); system. Out. println ( "GC. gettimeinmillis ():" + New Date (GC. gettimeinmillis ())); // Default Time Zone of the current system: Calendar calendar = New Gregoriancalendar (); system. Out. Print ( "Time Zone:" + calendar. gettimezone (). GETID () + "" ); System. Out. println ( "Time:" + calendar. Get (calendar. hour_of_day) + ":" + Calendar. Get (calendar. Minute )); // Los Angeles Time Zone Timezone TZ = timezone. gettimezone ("America/los_angeles" ); // Time zone conversion Calendar. settimezone (Tz); system. Out. Print ( "Time Zone:" + calendar. gettimezone (). GETID () + ""); System. Out. println ( "Time:" + calendar. Get (calendar. hour_of_day) + ":" + Calendar. Get (calendar. Minute); Date time = New Date (); // 1. obtain local time: Java. util. Calendar Cal = Java. util. Calendar. getinstance (); // 2. Get the Time Offset: Int Zoneoffset = Cal. Get (Java. util. Calendar. zone_offset ); // 3. Summer Time Difference: Int Dstoffset = Cal. Get (Java. util. Calendar. dst_offset ); // 4. deduct these differences from the local time to obtain the UTC time: Cal. Add (Java. util. Calendar. millisecond,-(zoneoffset + Dstoffset )); // The time obtained by calling the Cal. Get (int x) or Cal. gettimeinmillis () method is the UTC Standard Time. System. Out. println ("UTC:" + New Date (Cal. gettimeinmillis (); Calendar calendar1 =Calendar. getinstance (); timezone tztz = Timezone. gettimezone ("GMT" ); Calendar1.settimezone (tztz); system. Out. println (calendar. gettime (); system. Out. println (calendar. gettimeinmillis ());