November 17, 2003

Java Locales

So a while back we noticed a weird issue on our production servers - whenever a server was rebooted, when it came back up certain applications would have problems with SQL queries involving dates. The only way to fix the problem was to restart Tomcat. As server restarts are fairly rare, it took a while for us to gather the information via dumps of SQL queries when errors occurred.

The problem? When the default date format is used (e.g., with DateFormat.getDateInstance().format(date)), the string being returned was dd-mm-yyyy, instead of the expected MMM, dd yyyy. This caused Oracle’s to_date to fail.

The fix: explicitly set language and country in our startup scripts with -Duser.language=en -Duser.country=US.

Unfortunately, why the default locale is different on startup is still unclear; the same startup scripts are used for both init script startup and command-line restarts.

Posted by Bill Stilwell at November 17, 2003 01:47 PM
Comments