Today my tests started to fail even though I haven't changed anything for weeks (first day back after a period of illness). I have isolated the problem to the fact that when I call DateTime.toDateMidnight() it *sometimes* changes the offset from '+01:00' to 'Z'.
As an experienced programmer, the first thing I would be thinking after reading this is "muppet must be doing something stupid" only I don't think I am :). The following (groovy) snippet exhibits this behaviour: --- start @Test public void silly() { def days = 20 DateMidnight now = new DateTime() DateMidnight nowPlusDays = now.toDateTime().plusDays(days).toDateMidnight() def diff = nowPlusDays.millis - now.millis def expectedMillis = days * 24 * 60 * 60 * 1000 assertEquals expectedMillis, diff } --- end (I realise the above code isn't the optimal for the test but it is representative of what happens in production) Now - if I set "days" to be 7, for example, it works as expected. If I set it to be 20 then it fails. When I debug I can see that the toString method of now returns "2011-10-11T00:00:00.000+01:00" however nowPlusDays returns "2011-10-31T00:00:00.000Z". The iChronology of both of them is "ISOChronology[Europe/London]". This code has been working for years(!) although in production I am only ever using this to determine when things should expire so it may well be that I haven't picked it up. The tests are run on every checking (multiple times a day) and this is the first time it has failed. Any ideas - this has come completely out of the blue and I have no idea how to work around it. I am assuming it is a bug and I couldn't find any FAQ items related to this... On an aside - what is the idiomatic way to determine the number of whole days between two dates? I use DateMidnight as I thought that would simplify things ;). Many thanks, Col ------------------------------------------------------------------------------ All the data continuously generated in your IT infrastructure contains a definitive record of customers, application performance, security threats, fraudulent activity and more. Splunk takes this data and makes sense of it. Business sense. IT sense. Common sense. http://p.sf.net/sfu/splunk-d2d-oct _______________________________________________ Joda-interest mailing list Joda-interest@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/joda-interest