我正在使用此代码来解析此日期。它必须将新日期显示为“2012-06-20 03:09:38”,因为 EDT 是 -4GMT 而我当前的位置是 GMT+5。但它没有显示它现在显示它是
private static void convertEDT_TO_GMT() {
try {
String s = "2012-06-20 18:09:38";
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
df.setTimeZone(TimeZone.getTimeZone("EDT"));
Date timestamp = null;
timestamp = df.parse(s);
df.setTimeZone(TimeZone.getTimeZone("GMT+05:00"));
System.out.println("Old = " + s);
String parsed = df.format(timestamp);
System.out.println("New = " + parsed);
} catch (Exception e) {
e.printStackTrace();
}
}
它显示
旧 = 2012-06-20 18:09:38
新 = 2012-06-20 23:09:38