Well, guys, hello out there! I have recently faced a problem concerning calculation of the number of days between specific dates (within creating certain logic). I have simplified and cut off redundant code to show you the core of the problem. Below you will find a snap of the code that produces different output results for consecutive dates.
To demonstrate the trouble let us leave dateEnd unchanged and step up dateBegin from 2010,2,27 then 2010,2,28 then finally 2010,2,29
So, it performs correctly and gives out an integer and exact number of days between dateEnd and dateBegin correspondently 280,00 279,00 but when dateBegin is 2010,2,29 there comes out 278,04167 as the number of days.
Does anybody knows or has a slightest idea how to tackle this? Thanx.
GregorianCalendar dateBegin=new GregorianCalendar(2010,2,29);
GregorianCalendar dateEnd=new GregorianCalendar(2011,0,1);
SimpleDateFormat dtf=new SimpleDateFormat("dd/MM/yyyy H:m:s:S");
DecimalFormat ddtf=new DecimalFormat("0.00000");
When I run it I get this output:
Should say that the difference is exactly 1 hour.... Rather interesting thing don't u think?
Running on two different machines - result the same!
Build id: M20080911-1700
Nope, but will look into it if u believe it is the reason
Yep, that's the cause: 24022800000 millis is not a multiple of 24 hours (one hour too many). The Gregorian calendar anticipated on DST adjustment.
Originally Posted by Darryl.Burke
Well, thanx everybody for yr help and time spent. Now when i am directed to read up on DTS, hope i'll find cure for that mishap. Thanx!
Daylight Saving Time -- DST. Not DTS
sure)) thanx for correcting anyway