I tried that but with no effect :(

Sent from my iPad

On 11 Oct 2011, at 20:09, Mauro Ciancio <maurocian...@gmail.com> wrote:

Hi,
I'm very far from being a Joda Time expert but this kind of "weird" behavior
also happened to me a couple of years ago.
That had something to do with Time Zones and the fact that some instants are
not available (ie: do not exist) in specifics TimeZones. Could this be your
case?

You can always force the TimeZone to UTC when doing calculations so this
problem does not happen anymore.
See
http://joda-time.sourceforge.net/api-release/org/joda/time/LocalDate.html#toDateMidnight(org.joda.time.DateTimeZone)

Regards.

On Tue, Oct 11, 2011 at 3:56 PM, Colin Yates <colin.ya...@gmail.com> wrote:

> 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
>



-- 
Mauro Ciancio
http://about.me/maurociancio

------------------------------------------------------------------------------
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
------------------------------------------------------------------------------
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

Reply via email to