06-02-2011 03:55 AM
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
06-02-2011 04:20 AM
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.
06-02-2011 04:20 AM
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.
06-02-2011 04:40 AM
06-02-2011 04:46 AM