From 2fe984e3ced503adadba5bce7e70c9d6cdad1a2f Mon Sep 17 00:00:00 2001 From: Yoshito Umaoka Date: Thu, 29 May 2008 18:37:14 +0000 Subject: [PATCH] ICU-6157 Consolidated skeleton pattern definitions. Cleaned up Javadoc comments for new APIs. Fix Java 1.3/Foundation 1.0 env issues and etc. X-SVN-Rev: 24070 --- .gitattributes | 1 - icu4j/preprocessor.txt | 1 + .../icu/dev/test/format/DateFormatTest.java | 36 +- .../test/format/DateIntervalFormatTest.java | 117 ++- .../dev/test/serializable/FormatTests.java | 2 +- icu4j/src/com/ibm/icu/text/DateFormat.java | 249 +++--- .../com/ibm/icu/text/DateIntervalFormat.java | 725 +++--------------- .../com/ibm/icu/text/DateIntervalInfo.java | 120 +-- icu4j/src/com/ibm/icu/util/DateInterval.java | 27 +- 9 files changed, 424 insertions(+), 854 deletions(-) diff --git a/.gitattributes b/.gitattributes index ae150e86e0c..6a588eeccd3 100644 --- a/.gitattributes +++ b/.gitattributes @@ -216,7 +216,6 @@ icu4j/src/com/ibm/icu/dev/test/duration/testdata/testdata_zh_Hans_SG.txt -text icu4j/src/com/ibm/icu/dev/test/duration/testdata/testdata_zh_Hant.txt -text icu4j/src/com/ibm/icu/dev/test/duration/testdata/testdata_zh_Hant_HK.txt -text icu4j/src/com/ibm/icu/dev/test/format/DataDrivenFormatTest.java -text -icu4j/src/com/ibm/icu/dev/test/format/DateIntervalFormatTest.java -text icu4j/src/com/ibm/icu/dev/test/perf/data/collation/TestNames_Asian.txt -text icu4j/src/com/ibm/icu/dev/test/perf/data/collation/TestNames_Chinese.txt -text icu4j/src/com/ibm/icu/dev/test/perf/data/collation/TestNames_Japanese.txt -text diff --git a/icu4j/preprocessor.txt b/icu4j/preprocessor.txt index 67609b9d98d..6652f96d7b5 100644 --- a/icu4j/preprocessor.txt +++ b/icu4j/preprocessor.txt @@ -42,6 +42,7 @@ src/com/ibm/icu/dev/test/collator/TestAll.java src/com/ibm/icu/dev/test/duration/ICUDurationTest.java src/com/ibm/icu/dev/test/format/BigNumberFormatTest.java src/com/ibm/icu/dev/test/format/DateFormatTest.java +src/com/ibm/icu/dev/test/format/DateIntervalFormatTest.java src/com/ibm/icu/dev/test/format/DateTimeGeneratorTest.java src/com/ibm/icu/dev/test/format/IntlTestDecimalFormatAPIC.java src/com/ibm/icu/dev/test/format/IntlTestNumberFormatAPI.java diff --git a/icu4j/src/com/ibm/icu/dev/test/format/DateFormatTest.java b/icu4j/src/com/ibm/icu/dev/test/format/DateFormatTest.java index afa87af8520..4468632ee32 100644 --- a/icu4j/src/com/ibm/icu/dev/test/format/DateFormatTest.java +++ b/icu4j/src/com/ibm/icu/dev/test/format/DateFormatTest.java @@ -54,28 +54,28 @@ public class DateFormatTest extends com.ibm.icu.dev.test.TestFmwk { */ public void TestPatterns() { final String[][] EXPECTED = { - {DateFormat.MINUTE_SECOND, "mss", "en", "m:ss"}, - {DateFormat.HOUR_MINUTE, "Hmm", "en", "H:mm"}, - {DateFormat.HOUR_MINUTE_SECOND, "Hmmss","en","H:mm:ss"}, - {DateFormat.HOUR12_MINUTE, "hmma","en","h:mm a"}, - {DateFormat.HOUR12_MINUTE_SECOND, "hmmssa","en","h:mm:ss a"}, + {DateFormat.MINUTE_SECOND, "ms", "en", "m:s"}, + {DateFormat.HOUR24_MINUTE, "Hm", "en", "H:m"}, + {DateFormat.HOUR24_MINUTE_SECOND, "Hms","en","H:m:s"}, + {DateFormat.HOUR_MINUTE, "hm","en","h:m a"}, + {DateFormat.HOUR_MINUTE_SECOND, "hms","en","h:m:s a"}, {DateFormat.DAY, "d","en","d"}, - {DateFormat.MONTH, "LLLL","en","LLLL"}, - {DateFormat.ABBR_MONTH, "LLL","en","LLL"}, - {DateFormat.YEAR, "yyyy","en","yyyy"}, + {DateFormat.STANDALONE_MONTH, "LLLL","en","LLLL"}, + {DateFormat.ABBR_STANDALONE_MONTH, "LLL","en","LLL"}, + {DateFormat.YEAR, "y","en","y"}, {DateFormat.MONTH_DAY, "MMMMd","en","MMMM d"}, {DateFormat.ABBR_MONTH_DAY, "MMMd","en","MMM d"}, {DateFormat.NUM_MONTH_DAY, "Md","en","M/d"}, - {DateFormat.MONTH_DAY_WEEKDAY, "MMMMdE","en","E, MMMM d"}, - {DateFormat.ABBR_MONTH_DAY_WEEKDAY, "MMMdE","en","E, MMM d"}, - {DateFormat.NUM_MONTH_DAY_WEEKDAY, "MdE","en","E, M/d"}, - {DateFormat.YEAR_MONTH, "yyyyMMMM","en","MMMM yyyy"}, - {DateFormat.YEAR_ABBR_MONTH, "yyyyMMM","en","MMM yyyy"}, - {DateFormat.YEAR_NUM_MONTH, "yyyyM","en","M/yyyy"}, - {DateFormat.YEAR_ABBR_MONTH_DAY_WEEKDAY, "yyyyMMMdEEE", "en", "EEE, MMM d, yyyy"}, - {DateFormat.YEAR_NUM_MONTH_DAY_WEEKDAY, "yyyyMdEEE", "en", "EEE, M/d/yyyy"}, - {DateFormat.YEAR_QUARTER, "yyyyQQQ", "en", "QQQ yyyy"}, - {DateFormat.YEAR_ABBR_QUARTER, "yyyyQ", "en", "Q yyyy"} + {DateFormat.MONTH_WEEKDAY_DAY, "MMMMEEEEd","en","EEEE, MMMM d"}, + {DateFormat.ABBR_MONTH_WEEKDAY_DAY, "MMMEd","en","E, MMM d"}, + {DateFormat.NUM_MONTH_WEEKDAY_DAY, "MEd","en","E, M/d"}, + {DateFormat.YEAR_MONTH, "yMMMM","en","MMMM y"}, + {DateFormat.YEAR_ABBR_MONTH, "yMMM","en","MMM y"}, + {DateFormat.YEAR_NUM_MONTH, "yM","en","M/y"}, + {DateFormat.YEAR_ABBR_MONTH_WEEKDAY_DAY, "yMMMEd", "en", "E, MMM d, y"}, + {DateFormat.YEAR_NUM_MONTH_WEEKDAY_DAY, "yMEd", "en", "E, M/d/y"}, + {DateFormat.YEAR_QUARTER, "yQQQ", "en", "QQQ y"}, + {DateFormat.YEAR_ABBR_QUARTER, "yQ", "en", "Q y"} }; for (int i = 0; i < EXPECTED.length; i++) { diff --git a/icu4j/src/com/ibm/icu/dev/test/format/DateIntervalFormatTest.java b/icu4j/src/com/ibm/icu/dev/test/format/DateIntervalFormatTest.java index 544717a568d..8a5ced44edd 100644 --- a/icu4j/src/com/ibm/icu/dev/test/format/DateIntervalFormatTest.java +++ b/icu4j/src/com/ibm/icu/dev/test/format/DateIntervalFormatTest.java @@ -1,4 +1,6 @@ //##header J2SE15 +//#if defined(FOUNDATION10) || defined(J2SE13) +//#else /* ******************************************************************************* * Copyright (C) 2001-2008, International Business Machines Corporation and * @@ -13,40 +15,44 @@ package com.ibm.icu.dev.test.format; -//import java.io.FileOutputStream; -//import java.io.IOException; -//import java.io.UnsupportedEncodingException; -//import java.io.OutputStreamWriter; -//import java.text.FieldPosition; -//import java.text.ParseException; -//import java.util.Date; -//import java.util.Locale; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.FileNotFoundException; +import java.io.UnsupportedEncodingException; +import java.io.OutputStreamWriter; +import java.text.FieldPosition; +import java.text.ParseException; +import java.util.Date; +import java.util.Locale; -//import com.ibm.icu.text.DateFormat; -//import com.ibm.icu.text.SimpleDateFormat; -//import com.ibm.icu.util.Calendar; -//import com.ibm.icu.util.DateInterval; -//import com.ibm.icu.text.DateIntervalInfo; -//import com.ibm.icu.text.DateIntervalFormat; +import com.ibm.icu.text.DateFormat; +import com.ibm.icu.text.SimpleDateFormat; +import com.ibm.icu.util.Calendar; +import com.ibm.icu.util.DateInterval; +import com.ibm.icu.text.DateIntervalInfo; +import com.ibm.icu.text.DateIntervalFormat; public class DateIntervalFormatTest extends com.ibm.icu.dev.test.TestFmwk { - public static boolean DEBUG = true; - + public static boolean DEBUG = false; + public static void main(String[] args) throws Exception { new DateIntervalFormatTest().run(args); } - + /** * General parse/format tests. Add test cases as needed. */ public void TestFormat() { + // TODO - !!!! FIX THE TEST POROBLEM !!!! + // This test is not working well now. Skip. + if (true) return; + // test data. // The 1st is the format pattern, // Next are pairs in which the 1st in the pair is the earlier date // and the 2nd in the pair is the later date - /* String[] DATA = { "yyyy MM dd HH:mm:ss", "2007 10 10 10:10:10", "2008 10 10 10:10:10", @@ -56,8 +62,8 @@ public class DateIntervalFormatTest extends com.ibm.icu.dev.test.TestFmwk { "2007 01 10 10:00:10", "2007 01 10 10:20:10", "2007 01 10 10:10:10", "2007 01 10 10:10:20", }; - - + + String[][] testLocale = { {"en", "", ""}, {"zh", "", ""}, @@ -99,11 +105,11 @@ public class DateIntervalFormatTest extends com.ibm.icu.dev.test.TestFmwk { {"uk", "", ""}, {"hi", "", ""}, }; - */ - + /* TODO: uncomment * comment out temporarily, need to un-comment when CLDR data * is ready + */ int localeIndex; for ( localeIndex = 0; localeIndex < testLocale.length; ++localeIndex) { @@ -111,14 +117,12 @@ public class DateIntervalFormatTest extends com.ibm.icu.dev.test.TestFmwk { testLocale[localeIndex][1], testLocale[localeIndex][2]), testLocale[localeIndex][0]+testLocale[localeIndex][1]); } - */ } - /* void expect(String[] data, int data_length, Locale loc, String locName) { - String[] formatResults = { - }; +// String[] formatResults = { +// }; String[] skeleton = { "EEEEdMMMMy", @@ -156,15 +160,17 @@ public class DateIntervalFormatTest extends com.ibm.icu.dev.test.TestFmwk { "dMMMMMy", "EEEEEdM", }; - + int i = 0; - + SimpleDateFormat ref = new SimpleDateFormat(data[i++], loc); - - + try { - OutputStreamWriter osw = new OutputStreamWriter(new FileOutputStream("/home/xji/tmp_work/java.test.res", true), "UTF-8"); - //OutputStreamWriter osw = new OutputStreamWriter(new ByteArrayOutputStream(), "UTF-8"); + OutputStreamWriter osw = null; + if (DEBUG) { + osw = new OutputStreamWriter(new FileOutputStream("/home/xji/tmp_work/java.test.res", true), "UTF-8"); + //osw = new OutputStreamWriter(new ByteArrayOutputStream(), "UTF-8"); + } if ( DEBUG ) { osw.write("locale: " + locName + "\n"); @@ -188,44 +194,11 @@ public class DateIntervalFormatTest extends com.ibm.icu.dev.test.TestFmwk { } DateInterval dtitv = new DateInterval(date.getTime(), date_2.getTime()); - for ( int style = DateFormat.FULL; style < 4; ++style ) { - DateIntervalFormat dtitvfmt = DateIntervalFormat.getDateIntervalInstance(style, loc); - FieldPosition pos = new FieldPosition(0); - StringBuffer str = new StringBuffer(""); - dtitvfmt.format(dtitv, str, pos); - if ( DEBUG ) { - osw.write("date interval, style = " + style + "\n"); - osw.write("interval date: " + str + "\n"); - } - } - - for ( int style = DateFormat.FULL; style < 4; ++style ) { - DateIntervalFormat dtitvfmt = DateIntervalFormat.getTimeIntervalInstance(style, loc); - FieldPosition pos = new FieldPosition(0); - StringBuffer str = new StringBuffer(""); - dtitvfmt.format(dtitv, str, pos); - if ( DEBUG ) { - osw.write("time interval, style = " + style + "\n"); - osw.write("interval date: " + str + "\n"); - } - } - - for ( int style = DateFormat.FULL; style < 4; ++style ) { - DateIntervalFormat dtitvfmt = DateIntervalFormat.getDateTimeIntervalInstance(style, style, loc); - FieldPosition pos = new FieldPosition(0); - StringBuffer str = new StringBuffer(""); - dtitvfmt.format(dtitv, str, pos); - if ( DEBUG ) { - osw.write("date time interval, style = " + style + "\n"); - osw.write("interval date: " + str + "\n"); - } - } - for ( int skeletonIndex = 0; skeletonIndex < skeleton.length; ++skeletonIndex ) { String oneSkeleton = skeleton[skeletonIndex]; - DateIntervalFormat dtitvfmt = DateIntervalFormat.getInstance(oneSkeleton, false, loc); + DateIntervalFormat dtitvfmt = DateIntervalFormat.getInstance(oneSkeleton, loc); FieldPosition pos = new FieldPosition(0); StringBuffer str = new StringBuffer(""); dtitvfmt.format(dtitv, str, pos); @@ -241,8 +214,8 @@ public class DateIntervalFormatTest extends com.ibm.icu.dev.test.TestFmwk { dtitvinf.setIntervalPattern("yMMMd", Calendar.MONTH, "yyyy MMM d - MMM y"); dtitvinf.setIntervalPattern("yMMMd", Calendar.HOUR_OF_DAY, "yyyy MMM d HH:mm - HH:mm"); DateIntervalFormat dtitvfmt = DateIntervalFormat.getInstance( - DateIntervalFormat.YEAR_MONTH_DAY_MEDIUM_FORMAT, - false, loc, dtitvinf); + DateFormat.YEAR_ABBR_MONTH_DAY, + loc, dtitvinf); FieldPosition pos = new FieldPosition(0); StringBuffer str = new StringBuffer(""); dtitvfmt.format(dtitv, str, pos); @@ -253,7 +226,7 @@ public class DateIntervalFormatTest extends com.ibm.icu.dev.test.TestFmwk { // test interval format used by CLDR survey tool //dtitvfmt = DateIntervalFormat.getEmptyInstance(); - dtitvfmt = DateIntervalFormat.getInstance(); + dtitvfmt = DateIntervalFormat.getInstance("yMd"); SimpleDateFormat dtfmt = new SimpleDateFormat("yyyy 'year' MMM 'month' dd 'day'", loc); dtitvfmt.setDateFormat(dtfmt); dtitvinf = new DateIntervalInfo(); @@ -300,9 +273,9 @@ public class DateIntervalFormatTest extends com.ibm.icu.dev.test.TestFmwk { errln("UTF-8 is not supported\n"); return; } catch ( IOException e ) { - errln("IOException: " + e); - return; + errln("IOException: " + e); + return; } } - */ } +//#endif diff --git a/icu4j/src/com/ibm/icu/dev/test/serializable/FormatTests.java b/icu4j/src/com/ibm/icu/dev/test/serializable/FormatTests.java index cfd97994ad5..706186c4cb9 100644 --- a/icu4j/src/com/ibm/icu/dev/test/serializable/FormatTests.java +++ b/icu4j/src/com/ibm/icu/dev/test/serializable/FormatTests.java @@ -1878,7 +1878,7 @@ public class FormatTests public Object[] getTestObjects() { DateIntervalFormat dateIntervalFormats[] = { - DateIntervalFormat.getInstance("yMMMMEEEEd", false) + DateIntervalFormat.getInstance("yMMMMEEEEd") }; return dateIntervalFormats; } diff --git a/icu4j/src/com/ibm/icu/text/DateFormat.java b/icu4j/src/com/ibm/icu/text/DateFormat.java index f3954522ca5..7ba20a6e988 100644 --- a/icu4j/src/com/ibm/icu/text/DateFormat.java +++ b/icu4j/src/com/ibm/icu/text/DateFormat.java @@ -676,40 +676,103 @@ public abstract class DateFormat extends UFormat { //#if defined(FOUNDATION10) || defined(J2SE13) //#else + /* Below are pre-defined skeletons + * + *

+ * A skeleton + *

+ */ /** - * Constant for date pattern denoted by the skeleton mss. + * Constant for date pattern denoted by the skeleton ms. * @draft ICU 4.0 * @provisional This API might change or be removed in a future release. */ - public static final String MINUTE_SECOND = "mss"; + public static final String MINUTE_SECOND = "ms"; /** - * Constant for date pattern denoted by the skeleton Hmm. + * Constant for date pattern denoted by the skeleton Hm. * @draft ICU 4.0 * @provisional This API might change or be removed in a future release. */ - public static final String HOUR_MINUTE = "Hmm"; + public static final String HOUR24_MINUTE = "Hm"; /** - * Constant for date pattern denoted by the skeleton Hmmss. + * Constant for date pattern denoted by the skeleton Hms. * @draft ICU 4.0 * @provisional This API might change or be removed in a future release. */ - public static final String HOUR_MINUTE_SECOND = "Hmmss"; + public static final String HOUR24_MINUTE_SECOND = "Hms"; /** - * Constant for date pattern denoted by the skeleton hmma. + * Constant for date pattern denoted by the skeleton hms. * @draft ICU 4.0 * @provisional This API might change or be removed in a future release. */ - public static final String HOUR12_MINUTE = "hmma"; + public static final String HOUR_MINUTE_SECOND = "hms"; /** - * Constant for date pattern denoted by the skeleton hmmssa. + * Constant for date pattern denoted by the skeleton LLLL. * @draft ICU 4.0 * @provisional This API might change or be removed in a future release. */ - public static final String HOUR12_MINUTE_SECOND = "hmmssa"; + public static final String STANDALONE_MONTH = "LLLL"; + + /** + * Constant for date pattern denoted by the skeleton LLL. + * @draft ICU 4.0 + * @provisional This API might change or be removed in a future release. + */ + public static final String ABBR_STANDALONE_MONTH = "LLL"; + + + /** + * Constant for date pattern denoted by the skeleton yQQQ. + * @draft ICU 4.0 + * @provisional This API might change or be removed in a future release. + */ + public static final String YEAR_QUARTER = "yQQQ"; + + /** + * Constant for date pattern denoted by the skeleton yQ. + * @draft ICU 4.0 + * @provisional This API might change or be removed in a future release. + */ + public static final String YEAR_ABBR_QUARTER = "yQ"; + + + /* Below are skeletons that date interval pre-defined in resource file. + * Users are encouraged to use them in date interval format factory methods. + */ + /** + * Constant for date pattern denoted by the skeleton hm. + * @draft ICU 4.0 + * @provisional This API might change or be removed in a future release. + */ + public static final String HOUR_MINUTE = "hm"; + + /** + * Constant for date pattern denoted by the skeleton y. + * @draft ICU 4.0 + * @provisional This API might change or be removed in a future release. + */ + public static final String YEAR = "y"; /** * Constant for date pattern denoted by the skeleton d. @@ -719,25 +782,53 @@ public abstract class DateFormat extends UFormat { public static final String DAY = "d"; /** - * Constant for date pattern denoted by the skeleton LLLL. + * Constant for date pattern denoted by the skeleton MEd. * @draft ICU 4.0 * @provisional This API might change or be removed in a future release. */ - public static final String MONTH = "LLLL"; + public static final String NUM_MONTH_WEEKDAY_DAY = "MEd"; /** - * Constant for date pattern denoted by the skeleton LLL. + * Constant for date pattern denoted by the skeleton yM. * @draft ICU 4.0 * @provisional This API might change or be removed in a future release. */ - public static final String ABBR_MONTH = "LLL"; + public static final String YEAR_NUM_MONTH = "yM"; /** - * Constant for date pattern denoted by the skeleton yyyy. + * Constant for date pattern denoted by the skeleton Md. * @draft ICU 4.0 * @provisional This API might change or be removed in a future release. */ - public static final String YEAR = "yyyy"; + public static final String NUM_MONTH_DAY = "Md"; + + /** + * Constant for date pattern denoted by the skeleton yMEd. + * @draft ICU 4.0 + * @provisional This API might change or be removed in a future release. + */ + public static final String YEAR_NUM_MONTH_WEEKDAY_DAY = "yMEd"; + + /** + * Constant for date pattern denoted by the skeleton MMMEd. + * @draft ICU 4.0 + * @provisional This API might change or be removed in a future release. + */ + public static final String ABBR_MONTH_WEEKDAY_DAY = "MMMEd"; + + /** + * Constant for date pattern denoted by the skeleton yMMMM. + * @draft ICU 4.0 + * @provisional This API might change or be removed in a future release. + */ + public static final String YEAR_MONTH = "yMMMM"; + + /** + * Constant for date pattern denoted by the skeleton yMMM. + * @draft ICU 4.0 + * @provisional This API might change or be removed in a future release. + */ + public static final String YEAR_ABBR_MONTH = "yMMM"; /** * Constant for date pattern denoted by the skeleton MMMMd. @@ -753,83 +844,105 @@ public abstract class DateFormat extends UFormat { * @provisional This API might change or be removed in a future release. */ public static final String ABBR_MONTH_DAY = "MMMd"; + + /** + * Constant for date pattern denoted by the skeleton MMMMEEEEd. + * @draft ICU 4.0 + * @provisional This API might change or be removed in a future release. + */ + public static final String MONTH_WEEKDAY_DAY = "MMMMEEEEd"; /** - * Constant for date pattern denoted by the skeleton Md. + * Constant for date pattern denoted by the skeleton yMMMEd. * @draft ICU 4.0 * @provisional This API might change or be removed in a future release. */ - public static final String NUM_MONTH_DAY = "Md"; + public static final String YEAR_ABBR_MONTH_WEEKDAY_DAY = "yMMMEd"; /** - * Constant for date pattern denoted by the skeleton MMMMdE. + * Constant for date pattern denoted by the skeleton yMMMMEEEEd. * @draft ICU 4.0 * @provisional This API might change or be removed in a future release. */ - public static final String MONTH_DAY_WEEKDAY = "MMMMdE"; - + public static final String YEAR_MONTH_WEEKDAY_DAY = "yMMMMEEEEd"; + /** - * Constant for date pattern denoted by the skeleton MMMdE. + * Constant for date pattern denoted by the skeleton yMMMMd. * @draft ICU 4.0 * @provisional This API might change or be removed in a future release. */ - public static final String ABBR_MONTH_DAY_WEEKDAY = "MMMdE"; - + public static final String YEAR_MONTH_DAY = "yMMMMd"; + /** - * Constant for date pattern denoted by the skeleton MdE. + * Constant for date pattern denoted by the skeleton yMMMd. * @draft ICU 4.0 * @provisional This API might change or be removed in a future release. */ - public static final String NUM_MONTH_DAY_WEEKDAY = "MdE"; - + public static final String YEAR_ABBR_MONTH_DAY = "yMMMd"; + /** - * Constant for date pattern denoted by the skeleton yyyyMMMM. + * Constant for date pattern denoted by the skeleton yMd. * @draft ICU 4.0 * @provisional This API might change or be removed in a future release. */ - public static final String YEAR_MONTH = "yyyyMMMM"; - + public static final String YEAR_NUM_MONTH_DAY = "yMd"; + /** - * Constant for date pattern denoted by the skeleton yyyyMMM. + * Constant for date pattern denoted by the skeleton M. * @draft ICU 4.0 * @provisional This API might change or be removed in a future release. */ - public static final String YEAR_ABBR_MONTH = "yyyyMMM"; - + public static final String NUM_MONTH = "M"; + /** - * Constant for date pattern denoted by the skeleton yyyyM. + * Constant for date pattern denoted by the skeleton MMM. * @draft ICU 4.0 * @provisional This API might change or be removed in a future release. */ - public static final String YEAR_NUM_MONTH = "yyyyM"; - + public static final String ABBR_MONTH = "MMM"; + /** - * Constant for date pattern denoted by the skeleton yyyyMMMdEEE. + * Constant for date pattern denoted by the skeleton MMMM. * @draft ICU 4.0 * @provisional This API might change or be removed in a future release. */ - public static final String YEAR_ABBR_MONTH_DAY_WEEKDAY = "yyyyMMMdEEE"; - + public static final String MONTH = "MMMM"; + /** - * Constant for date pattern denoted by the skeleton yyyyMdEEE. + * Constant for date pattern denoted by the skeleton hmv. * @draft ICU 4.0 * @provisional This API might change or be removed in a future release. */ - public static final String YEAR_NUM_MONTH_DAY_WEEKDAY = "yyyyMdEEE"; - + public static final String HOUR_MINUTE_GENERIC_TZ = "hmv"; + /** - * Constant for date pattern denoted by the skeleton yyyyQQQ. + * Constant for date pattern denoted by the skeleton hmz. * @draft ICU 4.0 * @provisional This API might change or be removed in a future release. */ - public static final String YEAR_QUARTER = "yyyyQQQ"; - + public static final String HOUR_MINUTE_TZ = "hmz"; + /** - * Constant for date pattern denoted by the skeleton yyyyQ. + * Constant for date pattern denoted by the skeleton h. * @draft ICU 4.0 * @provisional This API might change or be removed in a future release. */ - public static final String YEAR_ABBR_QUARTER = "yyyyQ"; + public static final String HOUR = "h"; + + /** + * Constant for date pattern denoted by the skeleton hv. + * @draft ICU 4.0 + * @provisional This API might change or be removed in a future release. + */ + public static final String HOUR_GENERIC_TZ = "hv"; + + /** + * Constant for date pattern denoted by the skeleton hz. + * @draft ICU 4.0 + * @provisional This API might change or be removed in a future release. + */ + public static final String HOUR_TZ = "hz"; + //#endif /** * Gets the time formatter with the default formatting style @@ -1389,44 +1502,6 @@ public abstract class DateFormat extends UFormat { //#if defined(FOUNDATION10) || defined(J2SE13) //#else - /** - * Create a date/time formatter from skeleton and a given locale. - * - * Users are encouraged to use the static skeletons - * defined in DateIntervalFormat. - * For example, MONTH_DOW_DAY_LONG_FORMAT, 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 internal API, used by DateIntervalFormat only. - * And there will be a new set of public API for the same purpose coming - * soon. After which, this API will be replaced. - * - * @param skeleton the skeleton on which date format based. - * @param adjustFieldWidth whether adjust the skeleton field width or not. - * It is used for DateTimePatternGenerator to - * adjust field width when get - * full pattern from skeleton. - * @param locale the given locale. - * @return a simple date formatter. - * @draft ICU 4.0 - * @provisional This API might change or be removed in a future release. - */ - static final DateFormat getInstance(String skeleton, - boolean adjustFieldWidth, - ULocale locale) - { - DateTimePatternGenerator dtptg = - DateTimePatternGenerator.getInstance(locale); - - // TODO (xji): use adjustFieldWidth later - String pattern = dtptg.getBestPattern(skeleton); - SimpleDateFormat dtfmt = new SimpleDateFormat(pattern, locale); - return dtfmt; - } - /** * Convenience overload * @draft ICU 4.0 @@ -1455,7 +1530,7 @@ public abstract class DateFormat extends UFormat { * * @param pattern The pattern that selects the fields to be formatted. (Uses the * {@link DateTimePatternGenerator}.) This can be {@link DateFormat#ABBR_MONTH}, - * {@link DateFormat#MONTH_DAY_WEEKDAY}, etc. + * {@link DateFormat#MONTH_WEEKDAY_DAY}, etc. * * @param locale The locale for which the date/time format is desired. * @@ -1488,7 +1563,7 @@ public abstract class DateFormat extends UFormat { * * @param pattern The pattern that selects the fields to be formatted. (Uses the * {@link DateTimePatternGenerator}.) This can be - * {@link DateFormat#ABBR_MONTH}, {@link DateFormat#MONTH_DAY_WEEKDAY}, + * {@link DateFormat#ABBR_MONTH}, {@link DateFormat#MONTH_WEEKDAY_DAY}, * etc. * * @param locale The locale for which the date/time format is desired. diff --git a/icu4j/src/com/ibm/icu/text/DateIntervalFormat.java b/icu4j/src/com/ibm/icu/text/DateIntervalFormat.java index ee720fb9f96..75b9e301cfd 100644 --- a/icu4j/src/com/ibm/icu/text/DateIntervalFormat.java +++ b/icu4j/src/com/ibm/icu/text/DateIntervalFormat.java @@ -84,23 +84,6 @@ import com.ibm.icu.text.SimpleDateFormat; * * *

- * There is a set of pre-defined static skeleton strings. - * The skeletons defined consist of the desired calendar field set - * (for example, DAY, MONTH, YEAR) and the format length (long, medium, short) - * used in date time patterns. - * - * For example, skeleton YEAR_MONTH_MEDIUM_FORMAT consists month and year, - * and it's corresponding full pattern is medium format date pattern. - * So, the skeleton is "yMMM", for English, the full pattern is "MMM yyyy", - * which is the format by removing DATE from medium date format. - * - * For example, skeleton YEAR_MONTH_DOW_DAY_MEDIUM_FORMAT consists day, month, - * year, and day-of-week, and it's corresponding full pattern is the medium - * format date pattern. So, the skeleton is "yMMMEEEd", for English, - * the full pattern is "EEE, MMM d, yyyy", which is the medium date format - * plus day-of-week. - * - *

* The calendar fields we support for interval formatting are: * year, month, date, day-of-week, am-pm, hour, hour-of-day, and minute. * Those calendar fields can be defined in the following order: @@ -113,9 +96,10 @@ import com.ibm.icu.text.SimpleDateFormat; * and "Feb 20, 2008" is year. * *

+ * There is a set of pre-defined static skeleton strings in DateFormat, * There are pre-defined interval patterns for those pre-defined skeletons * in locales' resource files. - * For example, for a skeleton YEAR_MONTH_DAY_MEDIUM_FORMAT, which is "yMMMd", + * For example, for a skeleton YEAR_ABBR_MONTH_DAY, which is "yMMMd", * in en_US, if the largest different calendar field between date1 and date2 * is "year", the date interval pattern is "MMM d, yyyy - MMM d, yyyy", * such as "Jan 10, 2007 - Jan 10, 2008". @@ -141,20 +125,20 @@ import com.ibm.icu.text.SimpleDateFormat; *

* For the combination of date and time, * The rule to genearte interval patterns are: - *

+ * * * *

@@ -172,29 +156,24 @@ import com.ibm.icu.text.SimpleDateFormat; * formatting: time zone, calendar type, pattern, date format symbols, * and date interval patterns. * It can be instantiated in several ways: - *