-
Bug
-
Resolution: Won't Fix
-
P3
-
None
-
1.4.0
-
sparc
-
generic
Name: dfR10049 Date: 07/25/2001
java.text.MessageFormat.equals() ignores formats setting. It returns true even if
MessageFormat objects have different set of formatters.
This is the test demonstrating the bug:
------------------------------------------------------------------
import java.text.*;
public class Test {
public static void main (String args[]){
MessageFormat mf1 = new MessageFormat("pattern");
MessageFormat mf2 = new MessageFormat("pattern");
Format[] ff1 = {NumberFormat.getInstance()};
Format[] ff2 = {DateFormat.getTimeInstance()};
mf1.setFormats(ff1);
mf2.setFormats(ff2);
boolean eq = mf1.equals(mf2);
System.out.println("equals returns: " + eq);
if (eq)
System.out.println("Test failed");
else
System.out.println("Test passed");
}
}
---------------------------------------------------------------------
output from the test:
#> java -version
java version "1.4.0-beta_refresh"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-beta_refresh-b69)
Java HotSpot(TM) Client VM (build 1.4.0-beta_refresh-b69, mixed mode)
#> java Test
equals returns: true
Test failed
#> java Test
equals returns: false
Test passed
======================================================================