TimeZone 解决时区问题(2)
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
本文出自 “技术人生” 博客,请务必保留此出处http://zhaohaiyang.blog.51cto.com/2056753/465714
相关新闻>>
- 发表评论
-
- 最新评论 更多>>