From 5b8c96790b9b516fc20e918872a972205ba50986 Mon Sep 17 00:00:00 2001 From: Alan Liu Date: Fri, 15 Aug 2003 18:23:37 +0000 Subject: [PATCH] ICU-2966 add dateToString taking a TimeZone X-SVN-Rev: 12839 --- icu4c/source/test/intltest/caltztst.cpp | 19 +++++++++++++++++++ icu4c/source/test/intltest/caltztst.h | 1 + 2 files changed, 20 insertions(+) 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.