test/java/time/test/java/time/format/TestNonIsoFormatter.java

Print this page




  48 
  49 /**
  50  * Test DateTimeFormatter with non-ISO chronology.
  51  *
  52  * Strings in test data are all dependent on CLDR data which may change
  53  * in future CLDR releases.
  54  */
  55 @Test
  56 public class TestNonIsoFormatter {
  57     private static final Chronology ISO8601 = IsoChronology.INSTANCE;
  58     private static final Chronology JAPANESE = JapaneseChronology.INSTANCE;
  59     private static final Chronology HIJRAH = HijrahChronology.INSTANCE;
  60     private static final Chronology MINGUO = MinguoChronology.INSTANCE;
  61     private static final Chronology BUDDHIST = ThaiBuddhistChronology.INSTANCE;
  62 
  63     private static final LocalDate IsoDate = LocalDate.of(2013, 2, 11);
  64 
  65     private static final Locale ARABIC = new Locale("ar");
  66     private static final Locale thTH = new Locale("th", "TH");
  67     private static final Locale thTHTH = Locale.forLanguageTag("th-TH-u-nu-thai");

  68 
  69     @BeforeMethod
  70     public void setUp() {
  71     }
  72 
  73     @DataProvider(name="format_data")
  74     Object[][] formatData() {
  75         return new Object[][] {
  76             // Chronology, Format Locale, Numbering Locale, ChronoLocalDate, expected string
  77             { JAPANESE, Locale.JAPANESE, Locale.JAPANESE, JAPANESE.date(IsoDate),
  78               "\u5e73\u621025\u5e742\u670811\u65e5\u6708\u66dc\u65e5" }, // Japanese Heisei 25-02-11 (Mon)
  79             { HIJRAH, ARABIC, ARABIC, HIJRAH.date(IsoDate),
  80               "\u0627\u0644\u0627\u062b\u0646\u064a\u0646\u060c 1 \u0631\u0628\u064a\u0639 "
  81               + "\u0627\u0644\u0622\u062e\u0631 1434" }, // Hijrah AH 1434-04-01 (Mon)
  82             { MINGUO, Locale.TAIWAN, Locale.TAIWAN, MINGUO.date(IsoDate),
  83               "\u6c11\u570b102\u5e742\u670811\u65e5\u661f\u671f\u4e00" }, // Minguo ROC 102-02-11 (Mon)
  84             { BUDDHIST, thTH, thTH, BUDDHIST.date(IsoDate),
  85               "\u0e27\u0e31\u0e19\u0e08\u0e31\u0e19\u0e17\u0e23\u0e4c\u0e17\u0e35\u0e48"
  86               + " 11 \u0e01\u0e38\u0e21\u0e20\u0e32\u0e1e\u0e31\u0e19\u0e18\u0e4c"
  87               + " \u0e1e.\u0e28. 2556" }, // ThaiBuddhist BE 2556-02-11
  88             { BUDDHIST, thTH, thTHTH, BUDDHIST.date(IsoDate),
  89               "\u0e27\u0e31\u0e19\u0e08\u0e31\u0e19\u0e17\u0e23\u0e4c\u0e17\u0e35\u0e48 \u0e51\u0e51 "
  90               + "\u0e01\u0e38\u0e21\u0e20\u0e32\u0e1e\u0e31\u0e19\u0e18\u0e4c \u0e1e.\u0e28. "
  91               + "\u0e52\u0e55\u0e55\u0e56" }, // ThaiBuddhist BE 2556-02-11 (with Thai digits)
  92         };
  93     }
  94 
  95     @DataProvider(name="invalid_text")
  96     Object[][] invalidText() {
  97         return new Object[][] {
  98             // TODO: currently fixed Chronology and Locale.




  48 
  49 /**
  50  * Test DateTimeFormatter with non-ISO chronology.
  51  *
  52  * Strings in test data are all dependent on CLDR data which may change
  53  * in future CLDR releases.
  54  */
  55 @Test
  56 public class TestNonIsoFormatter {
  57     private static final Chronology ISO8601 = IsoChronology.INSTANCE;
  58     private static final Chronology JAPANESE = JapaneseChronology.INSTANCE;
  59     private static final Chronology HIJRAH = HijrahChronology.INSTANCE;
  60     private static final Chronology MINGUO = MinguoChronology.INSTANCE;
  61     private static final Chronology BUDDHIST = ThaiBuddhistChronology.INSTANCE;
  62 
  63     private static final LocalDate IsoDate = LocalDate.of(2013, 2, 11);
  64 
  65     private static final Locale ARABIC = new Locale("ar");
  66     private static final Locale thTH = new Locale("th", "TH");
  67     private static final Locale thTHTH = Locale.forLanguageTag("th-TH-u-nu-thai");
  68     private static final Locale jaJPJP = Locale.forLanguageTag("ja-JP-u-ca-japanese");
  69 
  70     @BeforeMethod
  71     public void setUp() {
  72     }
  73 
  74     @DataProvider(name="format_data")
  75     Object[][] formatData() {
  76         return new Object[][] {
  77             // Chronology, Format Locale, Numbering Locale, ChronoLocalDate, expected string
  78             { JAPANESE, Locale.JAPANESE, Locale.JAPANESE, JAPANESE.date(IsoDate),
  79               "\u5e73\u621025\u5e742\u670811\u65e5" }, // Japanese Heisei 25-02-11
  80             { HIJRAH, ARABIC, ARABIC, HIJRAH.date(IsoDate),
  81               "\u0627\u0644\u0627\u062b\u0646\u064a\u0646\u060c 1 \u0631\u0628\u064a\u0639 "
  82               + "\u0627\u0644\u0622\u062e\u0631 1434" }, // Hijrah AH 1434-04-01 (Mon)
  83             { MINGUO, Locale.TAIWAN, Locale.TAIWAN, MINGUO.date(IsoDate),
  84               "\u6c11\u570b102\u5e742\u670811\u65e5\u661f\u671f\u4e00" }, // Minguo ROC 102-02-11 (Mon)
  85             { BUDDHIST, thTH, thTH, BUDDHIST.date(IsoDate),
  86               "\u0e27\u0e31\u0e19\u0e08\u0e31\u0e19\u0e17\u0e23\u0e4c\u0e17\u0e35\u0e48"
  87               + " 11 \u0e01\u0e38\u0e21\u0e20\u0e32\u0e1e\u0e31\u0e19\u0e18\u0e4c"
  88               + " \u0e1e.\u0e28. 2556" }, // ThaiBuddhist BE 2556-02-11
  89             { BUDDHIST, thTH, thTHTH, BUDDHIST.date(IsoDate),
  90               "\u0e27\u0e31\u0e19\u0e08\u0e31\u0e19\u0e17\u0e23\u0e4c\u0e17\u0e35\u0e48 \u0e51\u0e51 "
  91               + "\u0e01\u0e38\u0e21\u0e20\u0e32\u0e1e\u0e31\u0e19\u0e18\u0e4c \u0e1e.\u0e28. "
  92               + "\u0e52\u0e55\u0e55\u0e56" }, // ThaiBuddhist BE 2556-02-11 (with Thai digits)
  93         };
  94     }
  95 
  96     @DataProvider(name="invalid_text")
  97     Object[][] invalidText() {
  98         return new Object[][] {
  99             // TODO: currently fixed Chronology and Locale.