开发者

Problem in changing String to date in blackberry?

i am using following code but the long values are not same any one can help me .

{
     long longCurrentTime=System.currentTimeMillis();
     System.out.println("Current time is..."+longCurrentTime);
     Date date=new Date(longCurrentTime);
     SimpleDateFormat dformat=new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss");
     String inStringTime=dformat.format(date);
     long byStringLongValue=HttpDateParser.parse(inStringTime);
     System.out.println("String to long conversion..."+byStringLongValue);

  }

in this code both long values开发者_Python百科 are coming different.

thanks


The reason is that your date format ignores the millisecond part.

Add the milliseconds part and verify the result.

 SimpleDateFormat dformat=new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss S");
                                                                         ^^^^
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜