Amit_MasterMInd
Amit_MasterMInd

Reputation: 80

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 are coming different.

thanks

Upvotes: 0

Views: 584

Answers (1)

Prince John Wesley
Prince John Wesley

Reputation: 63688

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");
                                                                         ^^^^

Upvotes: 1

Related Questions