TimeZone timeZoneLondon = TimeZone.getTimeZone("Europe/London");//格林威治Calendar cal=Calendar.getInstance(timeZoneLondon );
cal.set(2002,8,2);//2002-09-02
TimeZone timeZoneshanghai = TimeZone.getTimeZone("Asia/Shanghai");//北京时间
cal.setTimeZone(timeZoneshanghai);
cal.set(2002,8,2);//2002-09-02
TimeZone timeZoneshanghai = TimeZone.getTimeZone("Asia/Shanghai");//北京时间
cal.setTimeZone(timeZoneshanghai);
import java.util.TimeZone;
import java.util.Date;
import java.util.Locale;
import java.text.DateFormat;public class DateExample9 {public static void main(String[] args) {
Locale localeEN = Locale.US;
Locale localeFrance = Locale.FRANCE;TimeZone timeZoneMiami = TimeZone.getDefault();
TimeZone timeZoneParis = TimeZone.getTimeZone("Europe/Paris");DateFormat dateFormatter = DateFormat.getDateTimeInstance(
DateFormat.FULL,
DateFormat.FULL,
localeEN);
DateFormat dateFormatterParis = DateFormat.getDateTimeInstance(
DateFormat.FULL,
DateFormat.FULL,
localeFrance);Date curDate = new Date();System.out.println("Display for Miami office.");
// Print the Miami time zone display name in English
System.out.println(timeZoneMiami.getDisplayName(localeEN));
// Set the time zone of the dateFormatter to Miami time zone.
dateFormatter.setTimeZone(timeZoneMiami);
// Print the formatted date.
System.out.println(dateFormatter.format(curDate));// Set the time zone of the date formatter to Paris time zone.
dateFormatter.setTimeZone(timeZoneParis);
// Print the Paris time zone display name in English.
System.out.println(timeZoneParis.getDisplayName(localeEN));
// Print the Paris time in english.
System.out.println(dateFormatter.format(curDate));System.out.println("\nDisplay for Paris office.");
// Print the Miami time zone display name in French
System.out.println(timeZoneMiami.getDisplayName(localeFrance));
// Set the timezone of the
// dateFormatterParis to Miami time zone.
dateFormatterParis.setTimeZone(timeZoneMiami);
// Print the formatted date in French.
燬ystem.out.println(dateFormatterParis.format(curDate));// Set the timezone of the date formatter to Paris time zone.
dateFormatterParis.setTimeZone(timeZoneParis);
// Print the Paris time zone display name in French.
System.out.println(timeZoneParis.getDisplayName(localeFrance));
// Print the Paris time in French.
System.out.println(dateFormatterParis.format(curDate));
}
} 这个例子的输出是:Display for Miami office.
Eastern Standard Time
Friday, October 5, 2001 10:28:02 PM EDT
Central European Standard Time
Saturday, October 6, 2001 4:28:02 AM CEST
Display for Paris office.
GMT-05:00
vendredi 5 octobre 2001 22 h 28 GMT-04:00
GMT+01:00
samedi 6 octobre 2001 04 h 28 GMT+02:00
是这样吗?这很好办啊
java.util.GregorianCalendar ca = new java.util.GregorianCalendar(java.util.TimeZone.getTimeZone("GMT 00:00"));ca.set(2002, 9, 1, 00, 00, 00);java.text.SimpleDateFormat format=new java.text.SimpleDateFormat("yyyy/MM/dd HH:mm");format.setTimeZone(TimeZone.getTimeZone("Asia/Shanghai"));System.out.println( format1.format(ca.getTime()) );