开发者

Problem in changing String to date in blackberry?

开发者 https://www.devze.com 2023-03-14 17:59 出处:网络
i am using following code but the long values are not same any one can help me . { long longCurrentTime=System.currentTimeMillis();

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

精彩评论

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