harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sebb (JIRA)" <j...@apache.org>
Subject [jira] Created: (HARMONY-6400) SimpleDateFormat.parse produces erroneous results for 2-digit year with startdate 1900
Date Wed, 09 Dec 2009 17:36:18 GMT
SimpleDateFormat.parse produces erroneous results for 2-digit year with startdate 1900
--------------------------------------------------------------------------------------

                 Key: HARMONY-6400
                 URL: https://issues.apache.org/jira/browse/HARMONY-6400
             Project: Harmony
          Issue Type: Bug
          Components: Classlib
    Affects Versions: 5.0M12
         Environment: Apache Harmony (1.5.0)
DRLVM (11.2.0)
pre-alpha : not complete or compatible
svn = r885602, (Dec  1 2009), Windows/ia32/msvc 1500, release build
            Reporter: Sebb


Strange behaviour when parsing 2 digit years.

The following code works on RI, fails on Harmony:

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Locale;
import java.util.TimeZone;

import junit.framework.TestCase;

public class DateTests extends TestCase {
    private static final TimeZone TZ_GMT = TimeZone.getTimeZone("GMT");
    public void test2digitYear() throws Exception {
        Calendar calendar = Calendar.getInstance();
        calendar.setTimeZone(TZ_GMT);
        calendar.set(Calendar.MILLISECOND, 0);
        calendar.set(1900, Calendar.JANUARY, 0, 0, 0, 0);
        
        Date startDate = calendar.getTime(); 

        SimpleDateFormat formatYY = new SimpleDateFormat("dd-MMM-yy HH:mm:ss zzz", Locale.US);
        formatYY.setTimeZone(TZ_GMT);
        formatYY.set2DigitYearStart(startDate);

        calendar.set(1905, Calendar.OCTOBER, 14, 0, 0, 0);
        Date date1 = calendar.getTime(); 

        Date date2 = formatYY.parse("14-Oct-05 00:00:00 GMT");
        assertEquals(date1, date2);
    }

}

On Harmony, the error is:

AssertionFailedError: expected:<Sat Oct 14 00:00:00 Europe/London 1905> but was:<Sat
Oct 14 01:27:48 Europe/London 1905>

Note the rather odd time.

A similar test using start date of 2000 works OK.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message