ICU-6503 move createPatternInstance from DateFormat to DateIntervalFormat
X-SVN-Rev: 24884
This commit is contained in:
parent
98854bae7d
commit
a8aff4fc7b
@ -275,29 +275,6 @@ DateFormat::createInstance()
|
||||
return create(kShort, (EStyle) (kShort + kDateOffset), Locale::getDefault());
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
DateFormat* U_EXPORT2
|
||||
DateFormat::createPatternInstance(const UnicodeString& skeleton,
|
||||
const Locale& locale,
|
||||
DateTimePatternGenerator* dtpng,
|
||||
UErrorCode& status)
|
||||
{
|
||||
if ( U_FAILURE(status) ) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const UnicodeString pattern = dtpng->getBestPattern(skeleton, status);
|
||||
if ( U_FAILURE(status) ) {
|
||||
return NULL;
|
||||
}
|
||||
SimpleDateFormat* dtfmt = new SimpleDateFormat(pattern, locale, status);
|
||||
if ( U_FAILURE(status) ) {
|
||||
delete dtfmt;
|
||||
return NULL;
|
||||
}
|
||||
return dtfmt;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
DateFormat* U_EXPORT2
|
||||
|
@ -429,8 +429,8 @@ DateIntervalFormat::DateIntervalFormat(const Locale& locale,
|
||||
return;
|
||||
}
|
||||
fDtpng = DateTimePatternGenerator::createInstance(locale, status);
|
||||
DateFormat* dtfmt = DateFormat::createPatternInstance(*skeleton, locale,
|
||||
fDtpng, status);
|
||||
SimpleDateFormat* dtfmt = createSDFPatternInstance(*skeleton, locale,
|
||||
fDtpng, status);
|
||||
if ( U_FAILURE(status) ) {
|
||||
delete dtItvInfo;
|
||||
delete fDtpng;
|
||||
@ -449,7 +449,7 @@ DateIntervalFormat::DateIntervalFormat(const Locale& locale,
|
||||
fSkeleton = *skeleton;
|
||||
}
|
||||
fInfo = dtItvInfo;
|
||||
fDateFormat = (SimpleDateFormat*)dtfmt;
|
||||
fDateFormat = dtfmt;
|
||||
if ( dtfmt->getCalendar() ) {
|
||||
fFromCalendar = dtfmt->getCalendar()->clone();
|
||||
fToCalendar = dtfmt->getCalendar()->clone();
|
||||
@ -461,6 +461,28 @@ DateIntervalFormat::DateIntervalFormat(const Locale& locale,
|
||||
}
|
||||
|
||||
|
||||
SimpleDateFormat* U_EXPORT2
|
||||
DateIntervalFormat::createSDFPatternInstance(const UnicodeString& skeleton,
|
||||
const Locale& locale,
|
||||
DateTimePatternGenerator* dtpng,
|
||||
UErrorCode& status)
|
||||
{
|
||||
if ( U_FAILURE(status) ) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const UnicodeString pattern = dtpng->getBestPattern(skeleton, status);
|
||||
if ( U_FAILURE(status) ) {
|
||||
return NULL;
|
||||
}
|
||||
SimpleDateFormat* dtfmt = new SimpleDateFormat(pattern, locale, status);
|
||||
if ( U_FAILURE(status) ) {
|
||||
delete dtfmt;
|
||||
return NULL;
|
||||
}
|
||||
return dtfmt;
|
||||
}
|
||||
|
||||
|
||||
DateIntervalFormat* U_EXPORT2
|
||||
DateIntervalFormat::create(const Locale& locale,
|
||||
|
@ -414,36 +414,6 @@ public:
|
||||
*/
|
||||
static DateFormat* U_EXPORT2 createInstance(void);
|
||||
|
||||
/**
|
||||
* This is for ICU internal use only. Please do not use.
|
||||
* Create a date/time formatter from skeleton and a given locale.
|
||||
*
|
||||
* Users are encouraged to use the skeleton macros defined in udat.h.
|
||||
* For example, MONTH_WEEKDAY_DAY, which is "MMMMEEEEd",
|
||||
* and which means the pattern should have day, month, and day-of-week
|
||||
* fields, and follow the long date format defined in date time pattern.
|
||||
* For example, for English, the full pattern should be
|
||||
* "EEEE, MMMM d".
|
||||
*
|
||||
* Temporarily, this is an internal API, used by DateIntevalFormat only.
|
||||
* There will be a new set of APIs for the same purpose coming soon.
|
||||
* After which, this API will be replaced.
|
||||
*
|
||||
* @param skeleton the skeleton on which date format based.
|
||||
* @param locale the given locale.
|
||||
* @param dtpng the date time pattern generator.
|
||||
* @param status Output param to be set to success/failure code.
|
||||
* If it is failure, the returned date formatter will
|
||||
* be NULL.
|
||||
* @return a simple date formatter which the caller owns.
|
||||
* @internal ICU 4.0
|
||||
*/
|
||||
static DateFormat* U_EXPORT2 createPatternInstance(
|
||||
const UnicodeString& skeleton,
|
||||
const Locale& locale,
|
||||
DateTimePatternGenerator* dtpng,
|
||||
UErrorCode& status);
|
||||
|
||||
/**
|
||||
* Creates a time formatter with the given formatting style for the given
|
||||
* locale.
|
||||
|
@ -609,9 +609,28 @@ private:
|
||||
const UnicodeString* skeleton,
|
||||
UErrorCode& status);
|
||||
|
||||
/**
|
||||
* Create a simple date/time formatter from skeleton, given locale,
|
||||
* and date time pattern generator.
|
||||
*
|
||||
* @param skeleton the skeleton on which date format based.
|
||||
* @param locale the given locale.
|
||||
* @param dtpng the date time pattern generator.
|
||||
* @param status Output param to be set to success/failure code.
|
||||
* If it is failure, the returned date formatter will
|
||||
* be NULL.
|
||||
* @return a simple date formatter which the caller owns.
|
||||
* @internal ICU 4.0
|
||||
*/
|
||||
static SimpleDateFormat* U_EXPORT2 createSDFPatternInstance(
|
||||
const UnicodeString& skeleton,
|
||||
const Locale& locale,
|
||||
DateTimePatternGenerator* dtpng,
|
||||
UErrorCode& status);
|
||||
|
||||
|
||||
/**
|
||||
* Below are for generating interval patterns locale to the formatter
|
||||
* Below are for generating interval patterns local to the formatter
|
||||
*/
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user