我有这样的字符串2013-10-22T01:37:56.我需要将此字符串更改为UTC日期格式,如MM / dd / yyyy KK:mm:ss a.我已经尝试了一些代码,但它没有返回UTC datetime.
我的代码是
String[] time = itsAlarmDttm.split("T");
String aFormatDate = time[0]+ " "+time[1];
String aRevisedDate = null;
try {
final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
final Date dateObj = sdf.parse(aFormatDate);
aRevisedDate = new SimpleDateFormat("MM/dd/yyyy KK:mm:ss a").format(dateObj);
System.out.println(aRevisedDate);
} catch (ParseException e) {
itsLogger.error("Error occured in Parsing the Data Time Object: " +e.getMessage());
} catch (Exception e) {
itsLogger.error("Error occured in Data Time Objecct: " +e.getMessage());
}
我得到的输出是MM / dd / yyyy KK:mm:ss a格式.但不是UTC时间格式.
如何解决这个问题?