harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Svetlana Samoilenko (JIRA)" <j...@apache.org>
Subject [jira] Created: (HARMONY-1875) [classlib][text] java.text.MessageFormat.format(Object) rerurns result different from RI
Date Mon, 16 Oct 2006 09:41:37 GMT
[classlib][text] java.text.MessageFormat.format(Object) rerurns result different from RI
----------------------------------------------------------------------------------------

                 Key: HARMONY-1875
                 URL: http://issues.apache.org/jira/browse/HARMONY-1875
             Project: Harmony
          Issue Type: Bug
          Components: Classlib
            Reporter: Svetlana Samoilenko
            Priority: Minor


Description:
MessageFormat for format type "date" and  format style "subformat pattern" creates subformat
as SimpleDateFormat(subformatPattern, getLocale()).
According to the SimpleDateFormat specification  for year formatting if the number of pattern
letters is 2, the year is truncated to 2 digits; otherwise it is interpreted as a number.
For formatting number: the number of pattern letters is the minimum number of digits, and
shorter numbers are zero-padded to this amount.
Harmony does not add 0 before year if it is necessary while RI does.

Test for reproducing:

import junit.framework.TestCase; 
import java.text.*;
import java.util.*;
public class test extends TestCase {
    public void testFormat() {
        Locale.setDefault(Locale.CANADA);
        TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
        String pat="text here {0, date, yyyyyyyyy } and here";
        String etalon="text here  000002006  and here";           
        MessageFormat obj = new MessageFormat(pat); 
        assertEquals(etalon, obj.format(new Object[]{new Date((new Date().getTime()))}));
        
    }
}
HARMONY output:
==============
Apache Harmony Launcher : (c) Copyright 1991, 2006 The Apache Software Foundation or its licensors,
as applicable.
java version "1.5.0"
pre-alpha : not complete or compatible
svn = r453981, (Oct  9 2006), Windows/ia32/msvc 1310, release build http://incubator.apache.org/harmony
F
Time: 0.328
There was 1 failure:
1) testFormat(test)junit.framework.ComparisonFailure: expected:<...00000...> but was:<......>
        at test.testFormat(test.java:14)
        at java.lang.reflect.VMReflection.invokeMethod(Native Method)
FAILURES!!!
Tests run: 1,  Failures: 1,  Errors: 0

SUN output:
==========
java version "1.5.0_06"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_06-b05)
Java HotSpot(TM) Client VM (build 1.5.0_06-b05, mixed mode)
.
Time: 0.047
OK (1 test)



-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Mime
View raw message