PropertyFormatter and Locale

I am trying to write a property formatter for a monetary amount (and other types, but let’s consider this one as example). The property formatter shall be aware of user locale (to correctly format the field), but format and parse methods do not receive that information. Am I missing something? Is there another alternative?

A possibility would be to subclass PropertyFormatter, make it serializable (apparently it isn’t) and add a locale field with a setter, but this seems a quite tricky alternative.


You’re going along the right lines, but instead of adding a setter to the PropertyFormatter sub class, I would add a getLocale() method that gets the Application via the threadLocal pattern (something like
, and returns Application#getLocale()


class MyPropertyFormatter extends PropertyFormatter {
   public Locale getLocale(){
         return MyApplication.getMyApplication().getLocale();



Hi Charles,

Thank you very much indeed for your hint! I did not know about a reliable method (pattern) to get application instance. That will also save me the extra parameters I was passing to lot of constructors and functions.

Great and timely help!