开发者

converting milliseconds value to date?

consider the followign code:

public void convertTime()
{
    DateFormat df = new SimpleDateFormat(dateFormat);
    Date date;
    Date date2;

    date = df.parse("15/01/2010 21:58:54");
    date.getTime();                     //produces 1263585534000

    date2 = new Date(date.getTime());  //this is ok, compiles
    date2 = new Date(1263585534000);   //gives an error: The literal 1263585534000 of type int is out of range
}

I wonder how can i convert this long number into date format and why am i ge开发者_如何学Pythontting this error?

Thank you


1263585534000 is bigger than 2^31-1. Use L to indicate a Long.

date2 = new Date(1263585534000L);


date2 = new Date(1263585534000L);

ending with L for long literal to indicate it is a long number.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜