0
我打算在PST區域顯示時間。我發現了一種嵌入時間區域PDT的格式,但我想知道在冬天這是否會變成PST。在冬天,PDT會變爲PST嗎?
這就是代碼現在的樣子。
public static final String OUTPUT_FORMAT_STD_DATE6_TIMEZONE = "MM/dd/yy hh:mm a z";
public static String convertUTC(String strDate, String inputFormat, String outputFormat) {
String displayDateString = null;
try {
DateFormat inFormat = new SimpleDateFormat(inputFormat);
inFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
Date date = inFormat.parse(strDate);
DateFormat outFormat = new SimpleDateFormat(outputFormat);
outFormat.setTimeZone(TimeZone.getDefault());
displayDateString = formatDate(date, outputFormat);
} catch (ParseException pe) {
log.error("DateUtil.convertUTC :Parse exception while parsing,"+strDate+" using format :"+inputFormat) ;
}
return displayDateString;
}
public void endElement(String uri, String localName, String qName) throws SAXException {
if(EVENT.equalsIgnoreCase(qName)) {
auditEntries.add(entry);
} else if(LOG_TIME.equalsIgnoreCase(qName)) {
String time = content.toString();
entry.setLogTime(DateUtils.convertUTC(time, "yyyy-MM-dd'T'HH:mm:ss", DateUtils.OUTPUT_FORMAT_STD_DATE6_TIMEZONE));
}
時間顯示爲如下:
06/09/17 07:44 AM PDT
改變你的操作系統的時間,並找出:) –