I have been playing around with this idea and I have come up with a
better solution.
My original idea was to have a UtilMisc.getDefaultLocale() method that
would return the configured default locale - just like the existing
UtilDateTime.getDefaultTimeZone() returns the configured default time zone.
The disadvantage to that approach is that all Locale.getDefault() and
TimeZone.getDefault() method calls have to be changed to the utility
class method calls. An extensive and heavy-handed change.
There is a way to set the JVM default locale and time zone in Java. I'd
like to put that code in the Start class - so that those values are set
before any other classes are loaded (which may rely upon those defaults).
-Adrian
Adrian Crum wrote:
It seems the issue of default locale comes up with regularity. I believe
some of the confusion or problems come from the fact that the default
locale is not handled by the framework in a structured way.
Right now the only way to set the default locale is by setting it on the
machine the JVM is running on, or through a Java command line parameter.
I think it would be better to have the default locale configurable in
OFBiz.
It would be a trivial change to make and I think it will eliminate a lot
of quirky behavior.
Some time ago I tried a default locale implementation that was exactly
like the current implementation of the default time zone, and it worked
quite well. All code called a utility method to get the default locale,
and that method retrieved the default locale from a general.properties
setting.
What do you think?
-Adrian