+ return createDateTimeInstance(kShort, kShort, Locale::getDefault());
+}
+
+//----------------------------------------------------------------------
+
+DateFormat* U_EXPORT2
+DateFormat::createInstanceForSkeleton(
+ Calendar *calendarToAdopt,
+ const UnicodeString& skeleton,
+ const Locale &locale,
+ UErrorCode &status) {
+ LocalPointer<Calendar> calendar(calendarToAdopt);
+ if (U_FAILURE(status)) {
+ return NULL;
+ }
+ if (calendar.isNull()) {
+ status = U_ILLEGAL_ARGUMENT_ERROR;
+ return NULL;
+ }
+ DateFormat *result = createInstanceForSkeleton(skeleton, locale, status);
+ if (U_FAILURE(status)) {
+ return NULL;
+ }
+ result->adoptCalendar(calendar.orphan());
+ return result;
+}
+
+DateFormat* U_EXPORT2
+DateFormat::createInstanceForSkeleton(
+ const UnicodeString& skeleton,
+ const Locale &locale,
+ UErrorCode &status) {
+ LocalPointer<DateTimePatternGenerator> gen(
+ DateTimePatternGenerator::createInstance(locale, status));
+ if (U_FAILURE(status)) {
+ return NULL;
+ }
+ return internalCreateInstanceForSkeleton(
+ skeleton, locale, *gen, status);
+}
+
+DateFormat* U_EXPORT2
+DateFormat::createInstanceForSkeleton(
+ const UnicodeString& skeleton,
+ UErrorCode &status) {
+ return createInstanceForSkeleton(
+ skeleton, Locale::getDefault(), status);
+}
+
+DateFormat* U_EXPORT2
+DateFormat::internalCreateInstanceForSkeleton(
+ const UnicodeString& skeleton,
+ const Locale &locale,
+ DateTimePatternGenerator &gen,
+ UErrorCode &status) {
+ if (U_FAILURE(status)) {
+ return NULL;
+ }
+ DateFormat *fmt = new SimpleDateFormat(
+ gen.getBestPattern(skeleton, status),
+ locale,
+ status);
+ if (fmt == NULL) {
+ status = U_MEMORY_ALLOCATION_ERROR;
+ return NULL;
+ }
+ if (U_FAILURE(status)) {
+ delete fmt;
+ return NULL;
+ }
+ return fmt;