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. New to the forum? Please visit the ‘Getting Started’ link below.
inside custom component

Java Development

Reply
Contributor
vjava
Posts: 18
Registered: ‎06-02-2011
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

Please use plain text.
Developer
peter_strange
Posts: 17,702
Registered: ‎07-14-2008

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. 

Please use plain text.
Contributor
jasbeern
Posts: 17
Registered: ‎06-17-2010
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.

Please use plain text.
Contributor
vjava
Posts: 18
Registered: ‎06-02-2011
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
Please use plain text.
Contributor
vjava
Posts: 18
Registered: ‎06-02-2011
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
Please use plain text.