You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by "Tim Ellison (JIRA)" <ji...@apache.org> on 2006/12/08 16:00:30 UTC

[jira] Commented: (HARMONY-1875) [classlib][text] java.text.MessageFormat.format(Object) rerurns result different from RI

    [ http://issues.apache.org/jira/browse/HARMONY-1875?page=comments#action_12456860 ] 
            
Tim Ellison commented on HARMONY-1875:
--------------------------------------

I tried your patch and got a test failure as follows:

<code>
Wrong format: " yyyyy" expected: 1999 result: 01999

junit.framework.AssertionFailedError: Wrong format: " yyyyy" expected: 1999 result: 01999 at org.apache.harmony.text.tests.java.text.SimpleDateFormatTest$TestFormat.test(SimpleDateFormatTest.java:56) at org.apache.harmony.text.tests.java.text.SimpleDateFormatTest.test_formatLjava_util_DateLjava_lang_StringBufferLjava_text_FieldPosition(SimpleDateFormatTest.java:365) at java.lang.reflect.AccessibleObject.invokeV(AccessibleObject.java:25)
</code>

> [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
>         Attachments: H-1875-MessageFormatTest.patch, SimpleDateFormat.patch
>
>
> 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