Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Contributor
Posts: 18
Registered: ‎06-02-2011
My Device: touch
My Carrier: java

date comparision in java code black berry 6.0 sdk

Hi all

i need to compare to date object in my application we are using blackberry sdk 6.0

as statandard java calendar api we can use calendar.add method but it is not in the java uti provided by black berry can any oone help me how can i compare two date object.

 

i was using thsi code

 

   public static long calculateDays(Date dateEarly, Date dateLater) { 
      return (dateLater.getTime() - dateEarly.getTime()) / (FXConstants.MILLI_SECONDS_YEAR); 
     } 
    

but it gives me in correct results.

 

Please help me

Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: date comparison in java code black berry 6.0 sdk

Did you mean to code:

 

return (dateLater.getTime() - dateEarly.getTime()) / (DateTimeUtilities.ONEDAY); 

 

This code will not work over daylight saving periods because the time could get 1 hour short.  So, since you are rounding, you could just add 1 hour and that will make sure it is OK. 

Contributor
Posts: 17
Registered: ‎06-17-2010
My Device: C
My Carrier: SE

Re: date comparision in java code black berry 6.0 sdk

I also wanted to use Date API for formattig date, comparing date. Blackberry does not support all these functions well. You need to write your own logic as exist in jdk. I was expecting Date API's in JDE 6 but  these guys have not included Date API still.

Contributor
Posts: 18
Registered: ‎06-02-2011
My Device: touch
My Carrier: java

Re: date comparison in java code black berry 6.0 sdk

Hi thanks for your reply but can you explain it more when i should add 1 hour
Contributor
Posts: 18
Registered: ‎06-02-2011
My Device: touch
My Carrier: java

Re: date comparison in java code black berry 6.0 sdk

Hi peter, Thanks for your reply but can you explain it more when i should add 1 hour