-
Type:
Bug
-
Resolution: Fixed
-
Priority:
P2
-
Affects Version/s: 1.1.2, 1.1.5
-
Component/s: core-libs
-
1.1.6
-
x86
-
windows_nt
-
Verified
| Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
|---|---|---|---|---|---|---|
| JDK-2015706 | 1.2.0 | Norbert Lindenberg | P2 | Resolved | Fixed | 1.2beta3 |
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
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
- backported by
-
JDK-2015706 MessageFormat.setLocale doesn't change number or date formats
-
- Resolved
-
- relates to
-
JDK-5063449 Doc: MessageFormat.setLocale() does not affect format() method
-
- Resolved
-
-
JDK-4281978 MessageFormat's setLocale method does not work
-
- Closed
-
-
JDK-6452812 MessageFormat.setLocale() specification is incorrect
-
- Closed
-