我試圖使用JODA簡單地將一個數字時間戳(表示Unix紀元時間的long
)轉換爲一個Month Day, Year
字符串。JODA瘋狂?
這裏的代碼,我只是跑了幾秒鐘前:
long lTimestamp = 1315600867; // Current timestamp is approx 9/9/11 3:41 PM EST
DateTime oTimestamp = new DateTime(lTimestamp);
String strMon, strDay, strYear;
strMon = oTimestamp.monthOfYear().getAsText(Locale.ENGLISH);
strDay = oTimestamp.dayOfMonth().getAsText(Locale.ENGLISH);
strYear = oTimestamp.year().getAsText(Locale.ENGLISH);
String strDate = strMon + " " + strDay + ", " + strYear;
System.out.println("Converted timestamp is : " + strDate);
輸出到這是1970年1月16日!
難道這使得任何感任何人?!?!
我在http://www.epochconverter.com/上做了一個快速檢查。您的輸入很長是正確的。 – Freiheit
'DateTime'的'long'參數應該以毫秒爲單位,而不是秒。 – lhballoti
@Freiheit:epochconverter假設*秒*自紀元,而不是毫秒。 –