You wrote: ISO_W3C_DATE_TIME_FORMATTER = builder.toFormatter(); ISO_W3C_DATE_TIME_FORMATTER.withZoneUTC();
The second line has no effect, because the formatter is immutable, and you do not assign back the variable. This will work: ISO_W3C_DATE_TIME_FORMATTER = builder.toFormatter().withZoneUTC(); Your code is also similar to http://joda-time.sourceforge.net/api-release/org/joda/time/format/ISODateTimeFormat.html#localDateOptionalTimeParser%28%29 Stephen On 11 October 2012 00:04, John Jenkins <joje...@cens.ucla.edu> wrote: > I apologize if this has been answered / justified elsewhere, but I could not > find it. > > I am creating a parser based on the ISO year-month-day parser. I want to set > the default timezone of the returned object to UTC, but it is instead > defaulting to my local timezone. The code looks like this: > > ISODateTimeFormat.yearMonthDay().withZoneUTC().getParser(); > > The only pseduo-reasoning I have found was in the documentation: > > This will parse the text fully according to the formatter, using the UTC > zone. Once parsed, only the local date-time will be used. This means that > any parsed time-zone or offset field is completely ignored. It also means > that the zone and offset-parsed settings are ignored. > > What I expect to happen is that the string "2012-08-15" be decoded to a time > that represents midnight on August 15th, 2012 at UTC. Instead, I get that > date and time but at my local timezone, e.g. > "2012-08-15T00:00:00.000-07:00". > > I am just curious why this is. A colleague and I discussed it. The answer he > came up with is, because only a date is supplied, the time zone doesn't > matter. However, I would argue that, at 23:00 PM on December 31 it would > very much matter. The year, month, and day can all vary depending where you > are in the world, so all three values may be different. But, they do > represent the same moment in time. This can only be determined if the > timezone is also included. > > I attached the complete source, but I don't know if that will be preserved. > > Thank you, > > John > > > > ------------------------------------------------------------------------------ > Don't let slow site performance ruin your business. Deploy New Relic APM > Deploy New Relic app performance management and know exactly > what is happening inside your Ruby, Python, PHP, Java, and .NET app > Try New Relic at no cost today and get our sweet Data Nerd shirt too! > http://p.sf.net/sfu/newrelic-dev2dev > _______________________________________________ > Joda-interest mailing list > Joda-interest@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/joda-interest > ------------------------------------------------------------------------------ Don't let slow site performance ruin your business. Deploy New Relic APM Deploy New Relic app performance management and know exactly what is happening inside your Ruby, Python, PHP, Java, and .NET app Try New Relic at no cost today and get our sweet Data Nerd shirt too! http://p.sf.net/sfu/newrelic-dev2dev _______________________________________________ Joda-interest mailing list Joda-interest@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/joda-interest