ICU-2966 add dateToString taking a TimeZone

X-SVN-Rev: 12839
This commit is contained in:
Alan Liu 2003-08-15 18:23:37 +00:00
parent 2b85f8d379
commit 5b8c96790b
2 changed files with 20 additions and 0 deletions

View file

@ -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

View file

@ -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.