Custom Locale to use for a java application

Discussion in 'Java' started by Arbe, Jun 9, 2010.

  1. Arbe

    Arbe Guest

    I know I can create almost the Locale I want to use all over my
    application. I also can get a NumberFormat or DateFormat instance from
    that Locale, and use default formatting provided, or even customize
    that default formatting as desired.

    In the scenario I'm actually facing, I may have multiple different
    formats to apply for a single Locale. For instance NumberFormat has as
    available Locale fr_CA, but I might one to have different number
    formatting styles for fr_CA. For that reason makes sense to use the
    variant option on the Locale. Then I can have fr_CA_style1 and
    fr_CA_style2. Imagine I do:

    Locale locale = new Locale("fr","CA","style1");
    NumberFormat nf = NumberFormat.getCurrencyInstance(locale);

    That would five me the default NumberFormat for Locale.CANADA_FRENCH,
    as my custom Locale is not part of the number format defaults.

    The question then is, how can I customize/extend the list of available
    Locales on those Locale sensitive classes (NumberFormat or
    DateFormat), so when I try to get the instance I get my custom
    instance?

    Thanks in advance!
    Albert
    Arbe, Jun 9, 2010
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Maurice Hulsman
    Replies:
    1
    Views:
    1,830
    Guus Bosman
    Jul 25, 2004
  2. Replies:
    4
    Views:
    993
  3. Gabriel Genellina
    Replies:
    0
    Views:
    689
    Gabriel Genellina
    Feb 18, 2009
  4. zade
    Replies:
    1
    Views:
    597
    James Kanze
    Mar 5, 2010
  5. Sibylle Koczian
    Replies:
    2
    Views:
    1,096
    Sibylle Koczian
    Nov 20, 2010
Loading...

Share This Page