I added logger.info("Joda default time zone is: " +DateTimeZone.getDefault().getID()); and in the webapp it returns "Joda default time zone is: UTC" In contrast running the same code as a simple java test return Joda default time zone is: +01:00
Also notice within tomcat java Calendar returns the correct time zone "Time zone according to Calendar:Europe/Berlin" It looks to me like Joda is not picking up any time zone in Tomcat and defaulting to UTC - how does Joda determine the default time zone in tomcat? >You can print DateTimeZone.getDefault() to see what time zone JodaTime is >using. > >Stephen > > >2009/5/27 <e.mcgr...@imilia.com>: >> I have a time zone problem and I'm using the following code to try and >figure out what's going on: >> void test(){ >> Calendar cal = Calendar.getInstance(); >> logger.info("Time zone according to Calendar:" + > cal.getTimeZone().getID()); >> >> DateTime dateTime = >monthYearFormatter.parseDateTime("05.2009"); >> >> logger.info("Joda TimeZone is: " + >dateTime.getZone().getID()); >> >> LocalDate start = >dateTime.toLocalDate().dayOfMonth().withMinimumValue(); >> LocalDate end = start.plusMonths(1); >> >> Date d1 = start.toDateTimeAtStartOfDay().toDate(); >> Date d2 = end.toDateTimeAtStartOfDay().toDate(); >> >> logger.info("d1 = " + d1.toLocaleString()); >> logger.info("d2 = " + d2.toLocaleString()); >> } >> Running the code on the command line gives me correctly >> Time zone according to Calendar:GMT+01:00 >> Joda TimeZone is: +01:00 >> d1 = 01.05.2009 00:00:00 >> d2 = 01.06.2009 00:00:00 >> >> The exact same code running in Tomcat (5.5 also tested with 6.0) and on the >same machine as above (Tomcat has Europe/Berlin (CEST) as the time zone) gives >me >> Time zone according to Calendar:Europe/Berlin >> Joda TimeZone is: UTC >> d1 = 01.05.2009 02:00:00 >> d2 = 01.06.2009 02:00:00 >> >> Where is the UTC coming from? Is it because I'm parsing a date that doesn't >belong to any time zone? >> >> The problem is that I need to pass the java.util.Date instances on the jdbc >and the time part must be 00:00:00 in order for the query to work. >> >> >------------------------------------------------------------------------------ > >> Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT >> is a gathering of tech-side developers & brand creativity professionals. >Meet >> the minds behind Google Creative Lab, Visual Complexity, Processing, & >> iPhoneDevCamp as they present alongside digital heavyweights like Barbarian >> Group, R/GA, & Big Spaceship. http://p.sf.net/sfu/creativitycat-com >> _______________________________________________ >> Joda-interest mailing list >> Joda-interest@lists.sourceforge.net >> https://lists.sourceforge.net/lists/listinfo/joda-interest >> > >------------------------------------------------------------------------------ > >Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT >is a gathering of tech-side developers & brand creativity professionals. Meet >the minds behind Google Creative Lab, Visual Complexity, Processing, & >iPhoneDevCamp as they present alongside digital heavyweights like Barbarian >Group, R/GA, & Big Spaceship. http://p.sf.net/sfu/creativitycat-com >_______________________________________________ >Joda-interest mailing list >Joda-interest@lists.sourceforge.net >https://lists.sourceforge.net/lists/listinfo/joda-interest ------------------------------------------------------------------------------ OpenSolaris 2009.06 is a cutting edge operating system for enterprises looking to deploy the next generation of Solaris that includes the latest innovations from Sun and the OpenSource community. Download a copy and enjoy capabilities such as Networking, Storage and Virtualization. Go to: http://p.sf.net/sfu/opensolaris-get _______________________________________________ Joda-interest mailing list Joda-interest@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/joda-interest