我有一個顯示Mountain時區的字符串「2014-07-02T17:12:36.488-01:00」。我將其解析爲java.util.date格式。現在我需要將其轉換爲GMT格式。誰能幫我??如何將java.util.Date轉換爲GMT格式
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
Object dd = null;
try {
dd=sdf.parseObject("2014-07-02T17:12:36.488-01:00");
System.out.println(dd);
} catch (ParseException e) {
e.printStackTrace();`enter code here`
}
SimpleDateFormat gmtDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
gmtDateFormat.setTimeZone(java.util.TimeZone.getTimeZone("GMT"));
System.out.println("Current Date and Time in GMT time zone:+ gmtDateFormat.format(dd));
[轉換符合ISO8601字符串到java.util.Date](可能重複http://stackoverflow.com/questions/2201925/converting-iso8601-compliant-string-to-java- util-date) –