我從EST
服務器獲取日期字符串,所以我把它轉換UTC時間戳不返回正確的時間
例如日期2013-04-16T11:56:07.15
incidentDate = l.item(0).getTextContent();
DateFormat dformat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS",Locale.US);
dformat.setTimeZone(TimeZone.getTimeZone("America/New York"));
Date timestamp;
try
{
timestamp = dformat.parse(incidentDate);
incidentDateLong = timestamp.getTime();
}
catch (ParseException e1) {
e1.printStackTrace();
}
被返回的時間戳1366113367015
如果我將其插入本網站上的轉換器以檢查日期
http://www.ruddwire.com/handy-code/date-to-millisecond-calculators/
毫秒似乎不是正確的日期,它給我Tue Apr 16 2013 07:56:07 GMT-0400 (Eastern Daylight Time)
這是不是從服務器發送給我。
當我去的日期轉換回它拉追溯到甚至從實際日期
Date incDate = new Date(dateInMili);
DateFormat dformat = new SimpleDateFormat("MM/dd/yyyy hh:mm:ss a",Locale.US);
String dateStr = dformat.format(incDate);
漸行漸遠是有毛病我格式化?我不明白的問題
您應該檢查[這個問題和我的回答](http://stackoverflow.com/a/15994657/1122039) – Cebence