我想將當前日期轉換爲整數形式。默認情況下,它返回長。當我嘗試將long轉換爲整數,然後將整數值轉換爲日期意味着它顯示1970年代的日期。將當前日期轉換爲整數
int i = (int) new Date().getTime();
System.out.println("Integer : " + i);
System.out.println("Long : "+ new Date().getTime());
System.out.println("Long date : " + new Date(new Date().getTime()));
System.out.println("Int Date : " + new Date(i));
輸出將成爲
Integer : 1292838124
Long : 1345617601771
Long date : Wed Aug 22 12:10:01 IST 2012
Int Date : Fri Jan 16 04:37:18 IST 1970
任何一個請幫助我,如何爲當前日期轉換爲整數(10位數字)
O/P是:整數:1293630553, 長:1345618394201, 長日期:星期三8月22日12點23分14秒北京時間2012, 詮釋日期:星期五1月16日4時50分30秒IST 1970年 –
我認爲你給出了錯誤的輸出 –
抱歉我的錯誤..現在我改變它 – Bathakarai