java.time.chrono.JapaneseEra Java Examples
The following examples show how to use
java.time.chrono.JapaneseEra.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TCKJapaneseChronology.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
@Test public void test_with_TemporalField_long() { JapaneseDate base = JapaneseChronology.INSTANCE.date(JapaneseEra.SHOWA, 63, 6, 30); JapaneseDate test = base.with(YEAR, 1987); assertEquals(test, JapaneseChronology.INSTANCE.date(JapaneseEra.SHOWA, 62, 6, 30)); test = test.with(YEAR_OF_ERA, 2); assertEquals(test, JapaneseChronology.INSTANCE.date(JapaneseEra.SHOWA, 2, 6, 30)); test = test.with(ERA, JapaneseEra.HEISEI.getValue()); assertEquals(test, JapaneseChronology.INSTANCE.date(JapaneseEra.HEISEI, 2, 6, 30)); test = test.with(MONTH_OF_YEAR, 3); assertEquals(test, JapaneseChronology.INSTANCE.date(JapaneseEra.HEISEI, 2, 3, 30)); test = test.with(DAY_OF_MONTH, 4); assertEquals(test, JapaneseChronology.INSTANCE.date(JapaneseEra.HEISEI, 2, 3, 4)); }
Example #2
Source File: TCKJapaneseChronology.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 6 votes |
@DataProvider(name="prolepticYearError") Object[][] data_prolepticYearError() { return new Object[][] { {JapaneseEra.MEIJI, 100}, {JapaneseEra.MEIJI, 0}, {JapaneseEra.MEIJI, -10}, {JapaneseEra.SHOWA, 100}, {JapaneseEra.SHOWA, 0}, {JapaneseEra.SHOWA, -10}, {JapaneseEra.TAISHO, 100}, {JapaneseEra.TAISHO, 0}, {JapaneseEra.TAISHO, -10}, }; }
Example #3
Source File: TCKJapaneseChronology.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
@Test public void test_getDayOfYear() { // Test all the Eras for (JapaneseEra era : JapaneseEra.values()) { int firstYear = (era == JapaneseEra.MEIJI) ? 6 : 1; // Until Era supports range(YEAR_OF_ERA) JapaneseDate hd1 = JapaneseChronology.INSTANCE.dateYearDay(era, firstYear, 1); ValueRange range = hd1.range(DAY_OF_YEAR); assertEquals(range.getMaximum(), hd1.lengthOfYear(), "lengthOfYear should match range.getMaximum()"); for (int i = 1; i <= hd1.lengthOfYear(); i++) { JapaneseDate hd = JapaneseChronology.INSTANCE.dateYearDay(era, firstYear, i); int doy = hd.get(DAY_OF_YEAR); assertEquals(doy, i, "get(DAY_OF_YEAR) incorrect for " + i + ", of date: " + hd); } } }
Example #4
Source File: TCKJapaneseChronology.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 6 votes |
@DataProvider(name="prolepticYear") Object[][] data_prolepticYear() { return new Object[][] { {2, JapaneseEra.HEISEI, 1, 1 + YDIFF_HEISEI, false}, {2, JapaneseEra.HEISEI, 100, 100 + YDIFF_HEISEI, true}, {-1, JapaneseEra.MEIJI, 9, 9 + YDIFF_MEIJI, true}, {-1, JapaneseEra.MEIJI, 10, 10 + YDIFF_MEIJI, false}, {1, JapaneseEra.SHOWA, 1, 1 + YDIFF_SHOWA, false}, {1, JapaneseEra.SHOWA, 7, 7 + YDIFF_SHOWA, true}, {0, JapaneseEra.TAISHO, 1, 1 + YDIFF_TAISHO, true}, {0, JapaneseEra.TAISHO, 4, 4 + YDIFF_TAISHO, false}, }; }
Example #5
Source File: TCKJapaneseChronology.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
@DataProvider(name="prolepticYearError") Object[][] data_prolepticYearError() { return new Object[][] { {JapaneseEra.MEIJI, 100}, {JapaneseEra.MEIJI, 0}, {JapaneseEra.MEIJI, -10}, {JapaneseEra.SHOWA, 100}, {JapaneseEra.SHOWA, 0}, {JapaneseEra.SHOWA, -10}, {JapaneseEra.TAISHO, 100}, {JapaneseEra.TAISHO, 0}, {JapaneseEra.TAISHO, -10}, }; }
Example #6
Source File: TestJapaneseChronoImpl.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
@Test public void test_dayOfYearVsCalendar() { Locale locale = Locale.forLanguageTag("ja-JP-u-ca-japanese"); Calendar cal = java.util.Calendar.getInstance(locale); for (JapaneseEra era : JapaneseEra.values()) { for (int year : new int[] {6, 7}) { JapaneseDate jd = JapaneseChronology.INSTANCE.dateYearDay(era, year, 1); OffsetDateTime jodt = OffsetDateTime.of(LocalDate.from(jd), LocalTime.MIN, ZoneOffset.UTC); long millis = jodt.toInstant().toEpochMilli(); cal.setTimeZone(TimeZone.getTimeZone("GMT+00")); cal.setTimeInMillis(millis); assertEquals(jd.get(ChronoField.DAY_OF_YEAR), cal.get(Calendar.DAY_OF_YEAR), "different DAY_OF_YEAR values in " + era + ", year: " + year); assertEquals(jd.range(ChronoField.DAY_OF_YEAR).getMaximum(), cal.getActualMaximum(Calendar.DAY_OF_YEAR), "different maximum for DAY_OF_YEAR in " + era + ", year: " + year); assertEquals(jd.range(ChronoField.DAY_OF_YEAR).getMinimum(), cal.getActualMinimum(Calendar.DAY_OF_YEAR), "different minimum for DAY_OF_YEAR in " + era + ", year: " + year); } } }
Example #7
Source File: TCKJapaneseChronology.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
@DataProvider(name="prolepticYearError") Object[][] data_prolepticYearError() { return new Object[][] { {JapaneseEra.MEIJI, 100}, {JapaneseEra.MEIJI, 0}, {JapaneseEra.MEIJI, -10}, {JapaneseEra.SHOWA, 100}, {JapaneseEra.SHOWA, 0}, {JapaneseEra.SHOWA, -10}, {JapaneseEra.TAISHO, 100}, {JapaneseEra.TAISHO, 0}, {JapaneseEra.TAISHO, -10}, }; }
Example #8
Source File: TCKJapaneseChronology.java From hottub with GNU General Public License v2.0 | 6 votes |
@Test(dataProvider = "resolve_eymd") public void test_resolve_eymd(ResolverStyle style, JapaneseEra era, int yoe, int m, int d, JapaneseDate expected) { Map<TemporalField, Long> fieldValues = new HashMap<>(); fieldValues.put(ChronoField.ERA, (long) era.getValue()); fieldValues.put(ChronoField.YEAR_OF_ERA, (long) yoe); fieldValues.put(ChronoField.MONTH_OF_YEAR, (long) m); fieldValues.put(ChronoField.DAY_OF_MONTH, (long) d); if (expected != null) { JapaneseDate date = JapaneseChronology.INSTANCE.resolveDate(fieldValues, style); assertEquals(date, expected); assertEquals(fieldValues.size(), 0); } else { try { JapaneseChronology.INSTANCE.resolveDate(fieldValues, style); fail("Should have failed"); } catch (DateTimeException ex) { // expected } } }
Example #9
Source File: TestJapaneseChronoImpl.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
@Test public void test_dayOfYearVsCalendar() { Locale locale = Locale.forLanguageTag("ja-JP-u-ca-japanese"); Calendar cal = java.util.Calendar.getInstance(locale); for (JapaneseEra era : JapaneseEra.values()) { for (int year : new int[] {6, 7}) { JapaneseDate jd = JapaneseChronology.INSTANCE.dateYearDay(era, year, 1); OffsetDateTime jodt = OffsetDateTime.of(LocalDate.from(jd), LocalTime.MIN, ZoneOffset.UTC); long millis = jodt.toInstant().toEpochMilli(); cal.setTimeZone(TimeZone.getTimeZone("GMT+00")); cal.setTimeInMillis(millis); assertEquals(jd.get(ChronoField.DAY_OF_YEAR), cal.get(Calendar.DAY_OF_YEAR), "different DAY_OF_YEAR values in " + era + ", year: " + year); assertEquals(jd.range(ChronoField.DAY_OF_YEAR).getMaximum(), cal.getActualMaximum(Calendar.DAY_OF_YEAR), "different maximum for DAY_OF_YEAR in " + era + ", year: " + year); assertEquals(jd.range(ChronoField.DAY_OF_YEAR).getMinimum(), cal.getActualMinimum(Calendar.DAY_OF_YEAR), "different minimum for DAY_OF_YEAR in " + era + ", year: " + year); } } }
Example #10
Source File: TCKJapaneseChronology.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
@DataProvider(name="createByEra") Object[][] data_createByEra() { return new Object[][] { {JapaneseEra.HEISEI, 1996 - YDIFF_HEISEI, 2, 29, 60, LocalDate.of(1996, 2, 29)}, {JapaneseEra.HEISEI, 2000 - YDIFF_HEISEI, 2, 29, 60, LocalDate.of(2000, 2, 29)}, {JapaneseEra.MEIJI, 1874 - YDIFF_MEIJI, 2, 28, 59, LocalDate.of(1874, 2, 28)}, {JapaneseEra.SHOWA, 1928 - YDIFF_SHOWA, 12, 25, 360, LocalDate.of(1928, 12, 25)}, {JapaneseEra.TAISHO, 1916 - YDIFF_TAISHO, 7, 30, 212, LocalDate.of(1916, 7, 30)}, {JapaneseEra.MEIJI, 6, 1, 1, 1, LocalDate.of(1873, 1, 1)}, {JapaneseEra.MEIJI, 45, 7, 29, 211, LocalDate.of(1912, 7, 29)}, {JapaneseEra.TAISHO, 1, 7, 30, 1, LocalDate.of(1912, 7, 30)}, {JapaneseEra.TAISHO, 15, 12, 24, 358, LocalDate.of(1926, 12, 24)}, {JapaneseEra.SHOWA, 1, 12, 25, 1, LocalDate.of(1926, 12, 25)}, {JapaneseEra.SHOWA, 64, 1, 7, 7, LocalDate.of(1989, 1, 7)}, {JapaneseEra.HEISEI, 1, 1, 8, 1, LocalDate.of(1989, 1, 8)}, }; }
Example #11
Source File: TCKJapaneseChronology.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
@Test public void test_getDayOfYear() { // Test all the Eras for (JapaneseEra era : JapaneseEra.values()) { int firstYear = (era == JapaneseEra.MEIJI) ? 6 : 1; // Until Era supports range(YEAR_OF_ERA) JapaneseDate hd1 = JapaneseChronology.INSTANCE.dateYearDay(era, firstYear, 1); ValueRange range = hd1.range(DAY_OF_YEAR); assertEquals(range.getMaximum(), hd1.lengthOfYear(), "lengthOfYear should match range.getMaximum()"); for (int i = 1; i <= hd1.lengthOfYear(); i++) { JapaneseDate hd = JapaneseChronology.INSTANCE.dateYearDay(era, firstYear, i); int doy = hd.get(DAY_OF_YEAR); assertEquals(doy, i, "get(DAY_OF_YEAR) incorrect for " + i + ", of date: " + hd); } } }
Example #12
Source File: TCKJapaneseChronology.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
@DataProvider(name="prolepticYear") Object[][] data_prolepticYear() { return new Object[][] { {2, JapaneseEra.HEISEI, 1, 1 + YDIFF_HEISEI, false}, {2, JapaneseEra.HEISEI, 100, 100 + YDIFF_HEISEI, true}, {-1, JapaneseEra.MEIJI, 9, 9 + YDIFF_MEIJI, true}, {-1, JapaneseEra.MEIJI, 10, 10 + YDIFF_MEIJI, false}, {1, JapaneseEra.SHOWA, 1, 1 + YDIFF_SHOWA, false}, {1, JapaneseEra.SHOWA, 7, 7 + YDIFF_SHOWA, true}, {0, JapaneseEra.TAISHO, 1, 1 + YDIFF_TAISHO, true}, {0, JapaneseEra.TAISHO, 4, 4 + YDIFF_TAISHO, false}, }; }
Example #13
Source File: TCKJapaneseChronology.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
@DataProvider(name="createByEra") Object[][] data_createByEra() { return new Object[][] { {JapaneseEra.HEISEI, 1996 - YDIFF_HEISEI, 2, 29, 60, LocalDate.of(1996, 2, 29)}, {JapaneseEra.HEISEI, 2000 - YDIFF_HEISEI, 2, 29, 60, LocalDate.of(2000, 2, 29)}, {JapaneseEra.MEIJI, 1874 - YDIFF_MEIJI, 2, 28, 59, LocalDate.of(1874, 2, 28)}, {JapaneseEra.SHOWA, 1928 - YDIFF_SHOWA, 12, 25, 360, LocalDate.of(1928, 12, 25)}, {JapaneseEra.TAISHO, 1916 - YDIFF_TAISHO, 7, 30, 212, LocalDate.of(1916, 7, 30)}, {JapaneseEra.MEIJI, 6, 1, 1, 1, LocalDate.of(1873, 1, 1)}, {JapaneseEra.MEIJI, 45, 7, 29, 211, LocalDate.of(1912, 7, 29)}, {JapaneseEra.TAISHO, 1, 7, 30, 1, LocalDate.of(1912, 7, 30)}, {JapaneseEra.TAISHO, 15, 12, 24, 358, LocalDate.of(1926, 12, 24)}, {JapaneseEra.SHOWA, 1, 12, 25, 1, LocalDate.of(1926, 12, 25)}, {JapaneseEra.SHOWA, 64, 1, 7, 7, LocalDate.of(1989, 1, 7)}, {JapaneseEra.HEISEI, 1, 1, 8, 1, LocalDate.of(1989, 1, 8)}, }; }
Example #14
Source File: TCKJapaneseChronology.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 6 votes |
@Test public void test_with_TemporalField_long() { JapaneseDate base = JapaneseChronology.INSTANCE.date(JapaneseEra.SHOWA, 63, 6, 30); JapaneseDate test = base.with(YEAR, 1987); assertEquals(test, JapaneseChronology.INSTANCE.date(JapaneseEra.SHOWA, 62, 6, 30)); test = test.with(YEAR_OF_ERA, 2); assertEquals(test, JapaneseChronology.INSTANCE.date(JapaneseEra.SHOWA, 2, 6, 30)); test = test.with(ERA, JapaneseEra.HEISEI.getValue()); assertEquals(test, JapaneseChronology.INSTANCE.date(JapaneseEra.HEISEI, 2, 6, 30)); test = test.with(MONTH_OF_YEAR, 3); assertEquals(test, JapaneseChronology.INSTANCE.date(JapaneseEra.HEISEI, 2, 3, 30)); test = test.with(DAY_OF_MONTH, 4); assertEquals(test, JapaneseChronology.INSTANCE.date(JapaneseEra.HEISEI, 2, 3, 4)); }
Example #15
Source File: TestJapaneseChronoImpl.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
@Test public void test_dayOfYearVsCalendar() { Locale locale = Locale.forLanguageTag("ja-JP-u-ca-japanese"); Calendar cal = java.util.Calendar.getInstance(locale); for (JapaneseEra era : JapaneseEra.values()) { for (int year : new int[] {6, 7}) { JapaneseDate jd = JapaneseChronology.INSTANCE.dateYearDay(era, year, 1); OffsetDateTime jodt = OffsetDateTime.of(LocalDate.from(jd), LocalTime.MIN, ZoneOffset.UTC); long millis = jodt.toInstant().toEpochMilli(); cal.setTimeZone(TimeZone.getTimeZone("GMT+00")); cal.setTimeInMillis(millis); assertEquals(jd.get(ChronoField.DAY_OF_YEAR), cal.get(Calendar.DAY_OF_YEAR), "different DAY_OF_YEAR values in " + era + ", year: " + year); assertEquals(jd.range(ChronoField.DAY_OF_YEAR).getMaximum(), cal.getActualMaximum(Calendar.DAY_OF_YEAR), "different maximum for DAY_OF_YEAR in " + era + ", year: " + year); assertEquals(jd.range(ChronoField.DAY_OF_YEAR).getMinimum(), cal.getActualMinimum(Calendar.DAY_OF_YEAR), "different minimum for DAY_OF_YEAR in " + era + ", year: " + year); } } }
Example #16
Source File: TestJapaneseChronoImpl.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
@Test public void test_dayOfYearVsCalendar() { Locale locale = Locale.forLanguageTag("ja-JP-u-ca-japanese"); Calendar cal = java.util.Calendar.getInstance(locale); for (JapaneseEra era : JapaneseEra.values()) { for (int year : new int[] {6, 7}) { JapaneseDate jd = JapaneseChronology.INSTANCE.dateYearDay(era, year, 1); OffsetDateTime jodt = OffsetDateTime.of(LocalDate.from(jd), LocalTime.MIN, ZoneOffset.UTC); long millis = jodt.toInstant().toEpochMilli(); cal.setTimeZone(TimeZone.getTimeZone("GMT+00")); cal.setTimeInMillis(millis); assertEquals(jd.get(ChronoField.DAY_OF_YEAR), cal.get(Calendar.DAY_OF_YEAR), "different DAY_OF_YEAR values in " + era + ", year: " + year); assertEquals(jd.range(ChronoField.DAY_OF_YEAR).getMaximum(), cal.getActualMaximum(Calendar.DAY_OF_YEAR), "different maximum for DAY_OF_YEAR in " + era + ", year: " + year); assertEquals(jd.range(ChronoField.DAY_OF_YEAR).getMinimum(), cal.getActualMinimum(Calendar.DAY_OF_YEAR), "different minimum for DAY_OF_YEAR in " + era + ", year: " + year); } } }
Example #17
Source File: TCKJapaneseChronology.java From jdk8u_jdk with GNU General Public License v2.0 | 6 votes |
@Test public void test_getDayOfYear() { // Test all the Eras for (JapaneseEra era : JapaneseEra.values()) { int firstYear = (era == JapaneseEra.MEIJI) ? 6 : 1; // Until Era supports range(YEAR_OF_ERA) JapaneseDate hd1 = JapaneseChronology.INSTANCE.dateYearDay(era, firstYear, 1); ValueRange range = hd1.range(DAY_OF_YEAR); assertEquals(range.getMaximum(), hd1.lengthOfYear(), "lengthOfYear should match range.getMaximum()"); for (int i = 1; i <= hd1.lengthOfYear(); i++) { JapaneseDate hd = JapaneseChronology.INSTANCE.dateYearDay(era, firstYear, i); int doy = hd.get(DAY_OF_YEAR); assertEquals(doy, i, "get(DAY_OF_YEAR) incorrect for " + i + ", of date: " + hd); } } }
Example #18
Source File: TCKJapaneseChronology.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
@DataProvider(name="prolepticYear") Object[][] data_prolepticYear() { return new Object[][] { {2, JapaneseEra.HEISEI, 1, 1 + YDIFF_HEISEI, false}, {2, JapaneseEra.HEISEI, 100, 100 + YDIFF_HEISEI, true}, {-1, JapaneseEra.MEIJI, 9, 9 + YDIFF_MEIJI, true}, {-1, JapaneseEra.MEIJI, 10, 10 + YDIFF_MEIJI, false}, {1, JapaneseEra.SHOWA, 1, 1 + YDIFF_SHOWA, false}, {1, JapaneseEra.SHOWA, 7, 7 + YDIFF_SHOWA, true}, {0, JapaneseEra.TAISHO, 1, 1 + YDIFF_TAISHO, true}, {0, JapaneseEra.TAISHO, 4, 4 + YDIFF_TAISHO, false}, }; }
Example #19
Source File: JapanEraNameCompatTest.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
@Test(dataProvider="JavaTime") public void testChronoJapanEraDisplayName(Locale locale, String fullName, String shortName) { JapaneseEra era = JapaneseEra.valueOf("Reiwa"); assertEquals(era.getDisplayName(TextStyle.FULL, locale), fullName); assertEquals(era.getDisplayName(TextStyle.SHORT, locale), shortName); assertEquals(era.getDisplayName(TextStyle.NARROW, locale), "R"); }
Example #20
Source File: TCKJapaneseChronology.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
@Test(dataProvider="createByEra") public void test_createEyd(JapaneseEra era, int yoe, int moy, int dom, int doy, LocalDate iso) { JapaneseDate dateByChronoFactory = JapaneseChronology.INSTANCE.dateYearDay(era, yoe, doy); JapaneseDate dateByDateFactory = JapaneseDate.of(era, yoe, moy, dom); assertEquals(dateByChronoFactory, dateByDateFactory); assertEquals(dateByChronoFactory.hashCode(), dateByDateFactory.hashCode()); }
Example #21
Source File: TCKJapaneseChronology.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
public void test_resolve_yearOfEra_eraOnly_invalidTooSmall() { for (ResolverStyle style : ResolverStyle.values()) { Map<TemporalField, Long> fieldValues = new HashMap<>(); fieldValues.put(ChronoField.ERA, JapaneseEra.MEIJI.getValue() - 1L); try { JapaneseChronology.INSTANCE.resolveDate(fieldValues, style); fail("Should have failed: " + style); } catch (DateTimeException ex) { // expected } } }
Example #22
Source File: TCKJapaneseChronology.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
@Test public void test_JapaneseEra_values() { JapaneseEra[] actualEras = JapaneseEra.values(); Object[][] erasInfo = data_japanseseEras(); assertEquals(actualEras.length, erasInfo.length, "Wrong number of Eras"); for (int i = 0; i < erasInfo.length; i++) { Object[] eraInfo = erasInfo[i]; assertEquals(actualEras[i], eraInfo[0], "Singleton mismatch"); } }
Example #23
Source File: TCKJapaneseChronology.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
@Test(dataProvider = "resolve_styleByEra") public void test_resolve_yearOfEra_eraAndYearOfEraOnly_valid(ResolverStyle style, JapaneseEra era) { Map<TemporalField, Long> fieldValues = new HashMap<>(); fieldValues.put(ChronoField.ERA, (long) era.getValue()); fieldValues.put(ChronoField.YEAR_OF_ERA, 1L); JapaneseDate date = JapaneseChronology.INSTANCE.resolveDate(fieldValues, style); assertEquals(date, null); assertEquals(fieldValues.get(ChronoField.ERA), (Long) (long) era.getValue()); assertEquals(fieldValues.get(ChronoField.YEAR_OF_ERA), (Long) 1L); assertEquals(fieldValues.size(), 2); }
Example #24
Source File: TCKJapaneseChronology.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
@Test(dataProvider = "resolve_styleByEra") public void test_resolve_yearOfEra_eraOnly_valid(ResolverStyle style, JapaneseEra era) { Map<TemporalField, Long> fieldValues = new HashMap<>(); fieldValues.put(ChronoField.ERA, (long) era.getValue()); JapaneseDate date = JapaneseChronology.INSTANCE.resolveDate(fieldValues, style); assertEquals(date, null); assertEquals(fieldValues.get(ChronoField.ERA), (Long) (long) era.getValue()); assertEquals(fieldValues.size(), 1); }
Example #25
Source File: TCKJapaneseEra.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
@DataProvider(name = "JapaneseEras") Object[][] data_of_eras() { return new Object[][] { {JapaneseEra.of(3), "Reiwa", 3}, {JapaneseEra.HEISEI, "Heisei", 2}, {JapaneseEra.SHOWA, "Showa", 1}, {JapaneseEra.TAISHO, "Taisho", 0}, {JapaneseEra.MEIJI, "Meiji", -1}, }; }
Example #26
Source File: TCKJapaneseChronology.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
public void test_resolve_yearOfEra_eraOnly_invalidTooSmall() { for (ResolverStyle style : ResolverStyle.values()) { Map<TemporalField, Long> fieldValues = new HashMap<>(); fieldValues.put(ChronoField.ERA, JapaneseEra.MEIJI.getValue() - 1L); try { JapaneseChronology.INSTANCE.resolveDate(fieldValues, style); fail("Should have failed: " + style); } catch (DateTimeException ex) { // expected } } }
Example #27
Source File: TCKJapaneseChronology.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
@Test(dataProvider="japaneseEras") public void test_JapaneseEra_singletons(Era expectedEra, int eraValue, String name) { JapaneseEra actualEra = JapaneseEra.valueOf(name); assertEquals(actualEra, expectedEra, "JapaneseEra.valueOf(name)"); actualEra = JapaneseEra.of(eraValue); assertEquals(actualEra, expectedEra, "JapaneseEra.of(value)"); String string = actualEra.toString(); assertEquals(string, name, "JapaneseEra.toString()"); }
Example #28
Source File: TCKEraSerialization.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
@Test private void test_JapaneseErasSerialization() throws Exception { for (JapaneseEra era : JapaneseEra.values()) { assertSerializableSame(era); ByteArrayOutputStream baos = new ByteArrayOutputStream(); try (DataOutputStream dos = new DataOutputStream(baos) ) { dos.writeByte(JAPANESE_ERA_TYPE); dos.writeByte(era.getValue()); } byte[] bytes = baos.toByteArray(); assertSerializedBySer(era, bytes); } }
Example #29
Source File: TCKJapaneseChronology.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
@Test(dataProvider="createByEra") public void test_createEymd(JapaneseEra era, int yoe, int moy, int dom, int doy, LocalDate iso) { JapaneseDate dateByChronoFactory = JapaneseChronology.INSTANCE.date(era, yoe, moy, dom); JapaneseDate dateByDateFactory = JapaneseDate.of(era, yoe, moy, dom); assertEquals(dateByChronoFactory, dateByDateFactory); assertEquals(dateByChronoFactory.hashCode(), dateByDateFactory.hashCode()); }
Example #30
Source File: TCKJapaneseEra.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
@Test public void test_range() { // eras may be added after release for (JapaneseEra era : JapaneseEra.values()) { assertEquals(era.range(ERA).getMinimum(), -1); assertEquals(era.range(ERA).getLargestMinimum(), -1); assertEquals(era.range(ERA).getSmallestMaximum(), era.range(ERA).getMaximum()); assertEquals(era.range(ERA).getMaximum() >= 2, true); } }