android中的System.currentTimeMillis()?

Nar*_*vva 2 android date

System.currentTimeMillis(在我的项目中遇到问题 我在这里写了一些代码,我遇到了问题

Date currentDate = new Date(System.currentTimeMillis());
Log.v("1st",""+currentDate);    
Date currentDate = new Date(System.currentTimeMillis()+25*24*60*60*1000);
Log.v("2nd","25th"+currentDate);
Run Code Online (Sandbox Code Playgroud)

它显示当前日期在第一个日志中显示,但我将当前日期添加25天,它在第二个日志中,但它无法正常显示2个月后的日期.它在1*24*60*60*1000到24*24*60*60*1000天之间工作得非常好.在24下它不能正常工作请解决我的问题

提前致谢

小智 12

25*24*60*60*1000> Integer.MAX_VALUE,您应该写如下:

new Date(System.currentTimeMillis()+25*24*60*60*1000l);
Run Code Online (Sandbox Code Playgroud)


Bla*_*elt 9

使用日历,而不是

    Calendar rightNow = Calendar.getInstance()
    rightNow.add(Calendar.DAY_OF_YEAR, 25)
Run Code Online (Sandbox Code Playgroud)

你可以得到日期对象