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
Regular Contributor
sheetaloswal
Posts: 59
Registered: ‎03-06-2012
My Carrier: airtel
Accepted Solution

Issue in next prev logic

Hi All,

 

       I am performing the following logic for date decrease which is of the format 01 may 1989

ctimeMinus50Days = dateLong - 1L
                                * ((long) DateTimeUtilities.ONEDAY);
                    }

 

and for increase the logic is
                        ctimeMinus50Days = dateLong + 1L
                                * ((long) DateTimeUtilities.ONEDAY);

 

But when i try to increase the date its getting decreased alwasy whats wrong here

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

Re: Issue in next prev logic

Note sure why you aren't just coding this

 

ctimeMinus50Days = dateLong - 1L
                                * ((long) DateTimeUtilities.ONEDAY);

 

as

 

ctimeMinus50Days = dateLong -  ((long) DateTimeUtilities.ONEDAY);

 

Don't see why what you are dong isn't working.  What snippet of code can you show us the results of, that proves it isn't working?  Please make sure you just show us as small a section of code as possible, create a special test program if you have too. 

 

BTW, this arithmetic may not work as you want over Daylight Saving Time changes, when days are perhaps 23 hours or 25 hours. 

Please use plain text.
Regular Contributor
sheetaloswal
Posts: 59
Registered: ‎03-06-2012
My Carrier: airtel

Re: Issue in next prev logic

I have solved the issue,it was because of placement in managers.I did not get your last point about DST changes.What should i modify in my logic to include this
Please use plain text.
Developer
peter_strange
Posts: 19,511
Registered: ‎07-14-2008

Re: Issue in next prev logic

If this is solved, then please mark it as solved - see Instructions in Help link near the top.

 

"I did not get your last point about DST changes."

 

Say that today is the day that clocks go back and they go back 1 hour because of DST.  Then there are 25 hours in the day, not 24.  So you can't just add 24 hours. 

 

I woould like to be proved wrong, but the only way I have found to accurately move forward by one day is to take a Calendar Object,  set it to the start time, use DateTimeUtilities to zero the time (see the zeroCalendarTime() method), get the long time from the Calendar, add 36 hours, put this back into a Calendar Object, and then zero the time again.  Then I have the next day.  I think this will always work.  I'd love someone to suggest an easier way.....

Please use plain text.