diff --git a/icu4c/source/i18n/dtfmtsym.cpp b/icu4c/source/i18n/dtfmtsym.cpp index c1a4d8e889..b710170916 100644 --- a/icu4c/source/i18n/dtfmtsym.cpp +++ b/icu4c/source/i18n/dtfmtsym.cpp @@ -1987,7 +1987,7 @@ DateFormatSymbols::getZoneType(const UnicodeString& zid, const UnicodeString& te UnicodeString* strings = (UnicodeString*)fZoneStringsHash->get(zid); if(strings != NULL){ for(int32_t j=0; j0 && text.caseCompare(start, strings[j].length(), strings[j], 0)==0){ type = (TimeZoneTranslationType)j; value.setTo(strings[j]); return; diff --git a/icu4c/source/test/intltest/dtfmtrtts.cpp b/icu4c/source/test/intltest/dtfmtrtts.cpp index 89c51189b3..a4b59ab136 100644 --- a/icu4c/source/test/intltest/dtfmtrtts.cpp +++ b/icu4c/source/test/intltest/dtfmtrtts.cpp @@ -54,6 +54,7 @@ DateFormatRoundTripTest::runIndexedTest( int32_t index, UBool exec, const char* optionv = (par && *par=='v'); switch (index) { CASE(0,TestDateFormatRoundTrip) + CASE(1, TestCentury) default: name = ""; break; } } @@ -82,6 +83,25 @@ DateFormatRoundTripTest::failure(UErrorCode status, const char* msg, const Unico return FALSE; } +void DateFormatRoundTripTest::TestCentury() +{ + UErrorCode status = U_ZERO_ERROR; + Locale locale("es_PA"); + UnicodeString pattern = "MM/dd/yy hh:mm:ss a z"; + SimpleDateFormat fmt(pattern, locale, status); + UDate date[] = {-55018555891590.05, 0, 0}; + UnicodeString *result = new UnicodeString[2]; + + fmt.format(date[0], result[0]); + date[1] = fmt.parse(result[0], status); + fmt.format(date[1], result[1]); + date[2] = fmt.parse(result[1], status); + + if (date[1] != date[2] || result[0] != result[1]) { + errln("Round trip failure: \"%S\" (%f), \"%S\" (%f)", result[0].getBuffer(), date[1], result[1].getBuffer(), date[2]); + } +} + // == void DateFormatRoundTripTest::TestDateFormatRoundTrip() diff --git a/icu4c/source/test/intltest/dtfmtrtts.h b/icu4c/source/test/intltest/dtfmtrtts.h index 62db9e426e..1749d0e682 100644 --- a/icu4c/source/test/intltest/dtfmtrtts.h +++ b/icu4c/source/test/intltest/dtfmtrtts.h @@ -1,6 +1,6 @@ /******************************************************************** * COPYRIGHT: - * Copyright (c) 1997-2003, International Business Machines Corporation and + * Copyright (c) 1997-2006, International Business Machines Corporation and * others. All Rights Reserved. ********************************************************************/ @@ -30,6 +30,7 @@ public: virtual ~DateFormatRoundTripTest(); void TestDateFormatRoundTrip(void); + void TestCentury(void); void test(const Locale& loc); void test(DateFormat *fmt, const Locale &origLocale, UBool timeOnly = FALSE ); int32_t getField(UDate d, int32_t f);