The line new DateTime(start); will create a DateTime in your local
time-zone - GMT+1. Calling dt.toDateTime(DateTimeZone.UTC) will
convert to the same instant in UTC which is one hour earlier, hence
23:00.

Stephen


On 31 March 2010 08:20, Paul Carey <paul.p.ca...@gmail.com> wrote:
> Hi
>
> In the example below I would expect both date calculations to result
> in 2010-04-01T00:00:00.000Z. The 'Z' in the first datetime instance
> seems to not have the effect I would expect on the plusMonths
> calculation. If this is expected behaviour, I'd be grateful for an
> explanation.
>
> Many thanks
>
> Paul
>
> // joda 1.6, java 1.6, machine timezone GMT +1, no flags passed to
> javac or java
>
> import org.joda.time.DateTime;
> import org.joda.time.DateTimeZone;
>
> public class FooZone {
>
>    public static void main(String[] args) {
>        DateTime dt;
>        String start = "2010-01-01T00:00:00Z";
>
>        dt = new DateTime(start);
>        System.out.println(dt.toDateTime(DateTimeZone.UTC));
>      // 2010-01-01T00:00:00.000Z
>        System.out.println(dt.plusMonths(3).toDateTime(DateTimeZone.UTC));
>  // 2010-03-31T23:00:00.000Z
>
>        dt = new DateTime(start, DateTimeZone.UTC);
>        System.out.println(dt.plusMonths(3).toDateTime(DateTimeZone.UTC));
>  // 2010-04-01T00:00:00.000Z
>    }
> }
>
> ------------------------------------------------------------------------------
> Download Intel&#174; Parallel Studio Eval
> Try the new software tools for yourself. Speed compiling, find bugs
> proactively, and fine-tune applications for parallel performance.
> See why Intel Parallel Studio got high marks during beta.
> http://p.sf.net/sfu/intel-sw-dev
> _______________________________________________
> Joda-interest mailing list
> Joda-interest@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/joda-interest
>

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Joda-interest mailing list
Joda-interest@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/joda-interest

Reply via email to