カレンダーはそのようには機能しません...私はSimpleDateFormatコードを持っています..役立つかもしれません..これを試してください
public class TimeZoneTest {
public static void main(String[] args) {
new TimeZoneTest().setTimeZones();
}
private void setTimeZones(){
String etStart = "";
String ctStart = "";
String mtStart = "";
String ptStart = "";
DateFormat fullDateFormat = new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy");
String dateString = "Mon Mar 14 09:30:51 GMT 2011";
//this input date doesn't convert
//String dateString = "Mon Mar 14 09:30:51 PDT 2011";
System.out.println("Input Date: " + dateString);
System.out.println("Default TimeZone: " + TimeZone.getDefault());
try {
etStart = getDateInTimeZone(dateString, fullDateFormat, TimeZone.getTimeZone("America/New_York"));
ctStart = getDateInTimeZone(dateString, fullDateFormat, TimeZone.getTimeZone("America/Chicago"));
mtStart = getDateInTimeZone(dateString, fullDateFormat, TimeZone.getTimeZone("America/Denver"));
ptStart = getDateInTimeZone(dateString, fullDateFormat, TimeZone.getTimeZone("America/Los_Angeles"));
} catch (ParseException e) {
e.printStackTrace();
}
System.out.println("Eastern Date: " + etStart);
System.out.println("Central Date: " + ctStart);
System.out.println("Mountain Date: " + mtStart);
System.out.println("Pacific Date: " + ptStart);
}
private String getDateInTimeZone(Date inputDt, TimeZone targetTimeZone) throws ParseException{
DateFormat fullDateFormat = new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy");
fullDateFormat.setTimeZone(targetTimeZone);
return fullDateFormat.format(inputDt);
}
}