MessageFormat.setLocale doesn't change number or date formats

XMLWordPrintable

    • 1.1.6
    • x86
    • windows_nt
    • Verified

        Name: bb33257 Date: 06/13/97


        When you call MessageFormat.setLocale(aLocale) and then use
        the MessageFormat object, you'd expect that it would use the
        new locale's number and date formats. But it doesn't. It uses
        the NumberFormat and DateFormat objects that were cached when the
        MessageFormat was constucted, leading to numbers and dates
        formatted for the wrong locale

        FIX: When MessageFormat.setLocale is called, it should rebuild
        the cache of number and date formats using the new locale
        setting.
        ======================================================================
        Here is another failing case.

        import java.text.*;
        import java.awt.*;
        import java.applet.*;
        import java.util.*;



        // Test Java message formatting with positional parameters
        public class TestMsgFormat extends Applet {
           String errorMessage;
           String test="Error {0,number,integer} in {1} at {2,time,medium} on {2,date,long}";
           Object[] test_args = {
              new Integer(42),
              "File.foo",
              new Date()
           };
           MessageFormat msgFmt = new MessageFormat(test);
           public void init () {
            // Obtain the locale via params from the html page
             String initialLang = getParameter("Language");
             String initialTerr = getParameter("Territory");
              // Should do a sanity check on the actual value, but this will do for now
               String lang = (initialLang != null) ? initialLang : "en";
               String terr = (initialTerr != null) ? initialTerr : "US";
               Locale curLocale = new Locale(lang, terr);
               msgFmt.setLocale(curLocale);
              msgFmt.setLocale(Locale.GERMAN);
              errorMessage = msgFmt.format(test_args);
           }

           public void paint(Graphics g) {
                 g.setColor(Color.black);
                 g.drawString(errorMessage,10,10);
           }
        }
        ronan.mandel@Eng 1997-10-27

              Assignee:
              Norbert Lindenberg (Inactive)
              Reporter:
              Brian Beck (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: