diff --git a/icu4c/source/test/intltest/caltztst.cpp b/icu4c/source/test/intltest/caltztst.cpp index b9c438671de..3d50ce954c2 100644 --- a/icu4c/source/test/intltest/caltztst.cpp +++ b/icu4c/source/test/intltest/caltztst.cpp @@ -152,6 +152,25 @@ CalendarTimeZoneTest::dateToString(UDate d, UnicodeString& str) return str; } +UnicodeString& +CalendarTimeZoneTest::dateToString(UDate d, UnicodeString& str, + const TimeZone& tz) +{ + str.remove(); + DateFormat* format = getDateFormat(); + if (format == 0) + { + str += "DATE_FORMAT_FAILURE"; + return str; + } + TimeZone* save = format->getTimeZone().clone(); + format->setTimeZone(tz); + format->format(d, str); + format->adoptTimeZone(save); + releaseDateFormat(format); + return str; +} + // Utility methods to create a date. This is useful for converting Java constructs // which create a Date object. UDate diff --git a/icu4c/source/test/intltest/caltztst.h b/icu4c/source/test/intltest/caltztst.h index badf9e363c0..f9367830947 100644 --- a/icu4c/source/test/intltest/caltztst.h +++ b/icu4c/source/test/intltest/caltztst.h @@ -33,6 +33,7 @@ protected: // Tries to mimic the Java Date.toString() format. UnicodeString dateToString(UDate d); UnicodeString& dateToString(UDate d, UnicodeString& str); + UnicodeString& dateToString(UDate d, UnicodeString& str, const TimeZone& z); // Utility methods to create a date. This is useful for converting Java constructs // which create a Date object. Returns a Date in the current local time.