java.time.chrono.JapaneseDate Java Examples
The following examples show how to use
java.time.chrono.JapaneseDate.
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-dev-jdk with GNU General Public License v2.0 | 6 votes |
@Test public void test_dateNow(){ assertEquals(JapaneseChronology.INSTANCE.dateNow(), JapaneseDate.now()) ; assertEquals(JapaneseChronology.INSTANCE.dateNow(), JapaneseDate.now(ZoneId.systemDefault())) ; assertEquals(JapaneseChronology.INSTANCE.dateNow(), JapaneseDate.now(Clock.systemDefaultZone())) ; assertEquals(JapaneseChronology.INSTANCE.dateNow(), JapaneseDate.now(Clock.systemDefaultZone().getZone())) ; assertEquals(JapaneseChronology.INSTANCE.dateNow(), JapaneseChronology.INSTANCE.dateNow(ZoneId.systemDefault())) ; assertEquals(JapaneseChronology.INSTANCE.dateNow(), JapaneseChronology.INSTANCE.dateNow(Clock.systemDefaultZone())) ; assertEquals(JapaneseChronology.INSTANCE.dateNow(), JapaneseChronology.INSTANCE.dateNow(Clock.systemDefaultZone().getZone())) ; ZoneId zoneId = ZoneId.of("Europe/Paris"); assertEquals(JapaneseChronology.INSTANCE.dateNow(zoneId), JapaneseChronology.INSTANCE.dateNow(Clock.system(zoneId))) ; assertEquals(JapaneseChronology.INSTANCE.dateNow(zoneId), JapaneseChronology.INSTANCE.dateNow(Clock.system(zoneId).getZone())) ; assertEquals(JapaneseChronology.INSTANCE.dateNow(zoneId), JapaneseDate.now(Clock.system(zoneId))) ; assertEquals(JapaneseChronology.INSTANCE.dateNow(zoneId), JapaneseDate.now(Clock.system(zoneId).getZone())) ; assertEquals(JapaneseChronology.INSTANCE.dateNow(ZoneId.of(ZoneOffset.UTC.getId())), JapaneseChronology.INSTANCE.dateNow(Clock.systemUTC())) ; }
Example #2
Source File: TCKJapaneseChronology.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 6 votes |
@Test(dataProvider = "resolve_ymd") public void test_resolve_ymd_strict(int y, int m, int d, JapaneseDate expected, Object smart, boolean strict) { Map<TemporalField, Long> fieldValues = new HashMap<>(); fieldValues.put(ChronoField.YEAR, (long) y); fieldValues.put(ChronoField.MONTH_OF_YEAR, (long) m); fieldValues.put(ChronoField.DAY_OF_MONTH, (long) d); if (strict) { JapaneseDate date = JapaneseChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.STRICT); assertEquals(date, expected); assertEquals(fieldValues.size(), 0); } else { try { JapaneseChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.STRICT); fail("Should have failed"); } catch (DateTimeException ex) { // expected } } }
Example #3
Source File: TestJapaneseChronoImpl.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
@Test(dataProvider="RangeVersusCalendar") public void test_JapaneseChrono_vsCalendar(LocalDate isoStartDate, LocalDate isoEndDate) { Locale locale = Locale.forLanguageTag("ja-JP-u-ca-japanese"); assertEquals(locale.toString(), "ja_JP_#u-ca-japanese", "Unexpected locale"); Calendar cal = java.util.Calendar.getInstance(locale); assertEquals(cal.getCalendarType(), "japanese", "Unexpected calendar type"); JapaneseDate jDate = JapaneseChronology.INSTANCE.date(isoStartDate); // Convert to millis and set Japanese Calendar to that start date (at GMT) OffsetDateTime jodt = OffsetDateTime.of(isoStartDate, LocalTime.MIN, ZoneOffset.UTC); long millis = jodt.toInstant().toEpochMilli(); cal.setTimeZone(TimeZone.getTimeZone("GMT+00")); cal.setTimeInMillis(millis); while (jDate.isBefore(isoEndDate)) { assertEquals(jDate.get(ChronoField.DAY_OF_MONTH), cal.get(Calendar.DAY_OF_MONTH), "Day mismatch in " + jDate + "; cal: " + cal); assertEquals(jDate.get(ChronoField.MONTH_OF_YEAR), cal.get(Calendar.MONTH) + 1, "Month mismatch in " + jDate); assertEquals(jDate.get(ChronoField.YEAR_OF_ERA), cal.get(Calendar.YEAR), "Year mismatch in " + jDate); jDate = jDate.plus(1, ChronoUnit.DAYS); cal.add(Calendar.DAY_OF_MONTH, 1); } }
Example #4
Source File: Java8DatePropertyHandler.java From oxygen with Apache License 2.0 | 6 votes |
@Override public Object cast(Class<?> type, Object value) { Timestamp timestamp = new Timestamp(((Date) value).getTime()); if (type == Instant.class) { value = timestamp.toInstant(); } else if (type == JapaneseDate.class) { value = JapaneseDate.from(timestamp.toLocalDateTime()); } else if (type == LocalDateTime.class) { value = timestamp.toLocalDateTime(); } else if (type == LocalDate.class) { value = timestamp.toLocalDateTime().toLocalDate(); } else if (type == LocalTime.class) { value = timestamp.toLocalDateTime().toLocalTime(); } else if (type == OffsetDateTime.class) { value = OffsetDateTime.ofInstant(timestamp.toInstant(), ZoneId.systemDefault()); } else if (type == OffsetTime.class) { value = timestamp.toLocalDateTime().atOffset(OffsetDateTime.now().getOffset()).toOffsetTime(); } else if (type == ZonedDateTime.class) { value = ZonedDateTime.ofInstant(timestamp.toInstant(), ZoneId.systemDefault()); } return value; }
Example #5
Source File: TCKJapaneseChronology.java From openjdk-8-source 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 #6
Source File: TCKJapaneseChronology.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
@Test(dataProvider = "resolve_yd") public void test_resolve_yd_strict(int y, int d, JapaneseDate expected, boolean smart, boolean strict) { Map<TemporalField, Long> fieldValues = new HashMap<>(); fieldValues.put(ChronoField.YEAR, (long) y); fieldValues.put(ChronoField.DAY_OF_YEAR, (long) d); if (strict) { JapaneseDate date = JapaneseChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.STRICT); assertEquals(date, expected); assertEquals(fieldValues.size(), 0); } else { try { JapaneseChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.STRICT); fail("Should have failed"); } catch (DateTimeException ex) { // expected } } }
Example #7
Source File: TCKJapaneseChronology.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
@Test(dataProvider = "resolve_yd") public void test_resolve_yd_smart(int y, int d, JapaneseDate expected, boolean smart, boolean strict) { Map<TemporalField, Long> fieldValues = new HashMap<>(); fieldValues.put(ChronoField.YEAR, (long) y); fieldValues.put(ChronoField.DAY_OF_YEAR, (long) d); if (smart) { JapaneseDate date = JapaneseChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.SMART); assertEquals(date, expected); assertEquals(fieldValues.size(), 0); } else { try { JapaneseChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.SMART); fail("Should have failed"); } catch (DateTimeException ex) { // expected } } }
Example #8
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 #9
Source File: TCKJapaneseChronology.java From openjdk-jdk8u 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 #10
Source File: TestJapaneseChronoImpl.java From hottub 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 #11
Source File: TCKJapaneseChronology.java From TencentKona-8 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 #12
Source File: TCKJapaneseChronology.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
@Test(dataProvider = "resolve_yd") public void test_resolve_yd_strict(int y, int d, JapaneseDate expected, boolean smart, boolean strict) { Map<TemporalField, Long> fieldValues = new HashMap<>(); fieldValues.put(ChronoField.YEAR, (long) y); fieldValues.put(ChronoField.DAY_OF_YEAR, (long) d); if (strict) { JapaneseDate date = JapaneseChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.STRICT); assertEquals(date, expected); assertEquals(fieldValues.size(), 0); } else { try { JapaneseChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.STRICT); fail("Should have failed"); } catch (DateTimeException ex) { // expected } } }
Example #13
Source File: TCKJapaneseChronology.java From TencentKona-8 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 #14
Source File: TCKChronoLocalDateSerialization.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
@DataProvider(name = "calendars") Object[][] data_of_calendars() { return new Object[][]{ {JapaneseDate.of(JapaneseEra.HEISEI, 25, 01, 05), JAPANESE_DATE_TYPE}, {MinguoDate.of(102, 01, 05), MINGUO_DATE_TYPE}, {ThaiBuddhistDate.of(2556, 01, 05), THAIBUDDHIST_DATE_TYPE}, }; }
Example #15
Source File: TCKJapaneseChronology.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
@Test(dataProvider="createByProleptic") public void test_createYd(int y, int moy, int dom, int doy, LocalDate iso) { JapaneseDate dateByChronoFactory = JapaneseChronology.INSTANCE.dateYearDay(y, doy); JapaneseDate dateByDateFactory = JapaneseDate.of(y, moy, dom); assertEquals(dateByChronoFactory, dateByDateFactory); assertEquals(dateByChronoFactory.hashCode(), dateByDateFactory.hashCode()); }
Example #16
Source File: TCKJapaneseChronology.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
@Test(dataProvider = "resolve_styles") public void test_resolve_yearOfEra_yearOfEraAndYearOnly_valid(ResolverStyle style) { Map<TemporalField, Long> fieldValues = new HashMap<>(); fieldValues.put(ChronoField.YEAR_OF_ERA, 1L); fieldValues.put(ChronoField.YEAR, 2012L); JapaneseDate date = JapaneseChronology.INSTANCE.resolveDate(fieldValues, style); assertEquals(date, null); assertEquals(fieldValues.get(ChronoField.YEAR_OF_ERA), (Long) 1L); assertEquals(fieldValues.get(ChronoField.YEAR), (Long) 2012L); assertEquals(fieldValues.size(), 2); }
Example #17
Source File: TCKJapaneseChronology.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
@Test public void test_periodUntilDiffChrono() { JapaneseDate mdate1 = JapaneseDate.of(1970, 1, 1); JapaneseDate mdate2 = JapaneseDate.of(1971, 2, 2); MinguoDate ldate2 = MinguoChronology.INSTANCE.date(mdate2); ChronoPeriod period = mdate1.until(ldate2); assertEquals(period, JapaneseChronology.INSTANCE.period(1, 1, 1)); }
Example #18
Source File: TCKJapaneseChronology.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
@Test(dataProvider="createByProleptic") public void test_createYd(int y, int moy, int dom, int doy, LocalDate iso) { JapaneseDate dateByChronoFactory = JapaneseChronology.INSTANCE.dateYearDay(y, doy); JapaneseDate dateByDateFactory = JapaneseDate.of(y, moy, dom); assertEquals(dateByChronoFactory, dateByDateFactory); assertEquals(dateByChronoFactory.hashCode(), dateByDateFactory.hashCode()); }
Example #19
Source File: TCKJapaneseChronology.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
@Test(dataProvider="createByProleptic") public void test_createYmd(int y, int moy, int dom, int doy, LocalDate iso) { JapaneseDate dateByChronoFactory = JapaneseChronology.INSTANCE.date(y, moy, dom); JapaneseDate dateByDateFactory = JapaneseDate.of(y, moy, dom); assertEquals(dateByChronoFactory, dateByDateFactory); assertEquals(dateByChronoFactory.hashCode(), dateByDateFactory.hashCode()); }
Example #20
Source File: TCKJapaneseChronology.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
@Test(dataProvider = "resolve_ymd") public void test_resolve_ymd_lenient(int y, int m, int d, JapaneseDate expected, Object smart, boolean strict) { Map<TemporalField, Long> fieldValues = new HashMap<>(); fieldValues.put(ChronoField.YEAR, (long) y); fieldValues.put(ChronoField.MONTH_OF_YEAR, (long) m); fieldValues.put(ChronoField.DAY_OF_MONTH, (long) d); JapaneseDate date = JapaneseChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.LENIENT); assertEquals(date, expected); assertEquals(fieldValues.size(), 0); }
Example #21
Source File: TCKJapaneseChronology.java From TencentKona-8 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 #22
Source File: TestUmmAlQuraChronology.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
@DataProvider(name="localDateTime") Object[][] data_localDateTime() { return new Object[][] { {LocalDateTime.of(2012, 2, 29, 2, 7), HijrahChronology.INSTANCE.date(1433, 4, 7), LocalTime.of(2, 7), null}, {ZonedDateTime.of(2012, 2, 29, 2, 7, 1, 1, ZONE_RIYADH), HijrahChronology.INSTANCE.date(1433, 4, 7), LocalTime.of(2, 7, 1, 1), null}, {OffsetDateTime.of(2012, 2, 29, 2, 7, 1, 1, OFFSET_PTWO), HijrahChronology.INSTANCE.date(1433, 4, 7), LocalTime.of(2, 7, 1, 1), null}, {JapaneseDate.of(2012, 2, 29), null, null, DateTimeException.class}, {ThaiBuddhistDate.of(2012 + 543, 2, 29), null, null, DateTimeException.class}, {LocalDate.of(2012, 2, 29), null, null, DateTimeException.class}, {LocalTime.of(20, 30, 29, 0), null, null, DateTimeException.class}, }; }
Example #23
Source File: TCKChronoLocalDateSerialization.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
@DataProvider(name = "calendars") Object[][] data_of_calendars() { return new Object[][]{ {JapaneseDate.of(JapaneseEra.HEISEI, 25, 01, 05), JAPANESE_DATE_TYPE}, {MinguoDate.of(102, 01, 05), MINGUO_DATE_TYPE}, {ThaiBuddhistDate.of(2556, 01, 05), THAIBUDDHIST_DATE_TYPE}, }; }
Example #24
Source File: TCKJapaneseChronology.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
@Test(dataProvider = "resolve_styles") public void test_resolve_yearOfEra_yearOfEraAndYearOnly_valid(ResolverStyle style) { Map<TemporalField, Long> fieldValues = new HashMap<>(); fieldValues.put(ChronoField.YEAR_OF_ERA, 1L); fieldValues.put(ChronoField.YEAR, 2012L); JapaneseDate date = JapaneseChronology.INSTANCE.resolveDate(fieldValues, style); assertEquals(date, null); assertEquals(fieldValues.get(ChronoField.YEAR_OF_ERA), (Long) 1L); assertEquals(fieldValues.get(ChronoField.YEAR), (Long) 2012L); assertEquals(fieldValues.size(), 2); }
Example #25
Source File: TCKChronoLocalDateSerialization.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
@DataProvider(name = "calendars") Object[][] data_of_calendars() { return new Object[][]{ {JapaneseDate.of(JapaneseEra.HEISEI, 25, 01, 05), JAPANESE_DATE_TYPE}, {MinguoDate.of(102, 01, 05), MINGUO_DATE_TYPE}, {ThaiBuddhistDate.of(2556, 01, 05), THAIBUDDHIST_DATE_TYPE}, }; }
Example #26
Source File: TestUmmAlQuraChronology.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
@DataProvider(name="zonedDateTime") Object[][] data_zonedDateTime() { return new Object[][] { {ZonedDateTime.of(2012, 2, 29, 2, 7, 1, 1, ZONE_RIYADH), HijrahChronology.INSTANCE.date(1433, 4, 7), LocalTime.of(2, 7, 1, 1), null}, {OffsetDateTime.of(2012, 2, 29, 2, 7, 1, 1, OFFSET_PTWO), HijrahChronology.INSTANCE.date(1433, 4, 7), LocalTime.of(2, 7, 1, 1), null}, {LocalDateTime.of(2012, 2, 29, 2, 7), null, null, DateTimeException.class}, {JapaneseDate.of(2012, 2, 29), null, null, DateTimeException.class}, {ThaiBuddhistDate.of(2012 + 543, 2, 29), null, null, DateTimeException.class}, {LocalDate.of(2012, 2, 29), null, null, DateTimeException.class}, {LocalTime.of(20, 30, 29, 0), null, null, DateTimeException.class}, }; }
Example #27
Source File: TCKJapaneseChronology.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
@Test public void test_periodUntilDate() { JapaneseDate mdate1 = JapaneseDate.of(1970, 1, 1); JapaneseDate mdate2 = JapaneseDate.of(1971, 2, 2); ChronoPeriod period = mdate1.until(mdate2); assertEquals(period, JapaneseChronology.INSTANCE.period(1, 1, 1)); }
Example #28
Source File: TCKMinguoChronology.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
@DataProvider(name="localDateTime") Object[][] data_localDateTime() { return new Object[][] { {LocalDateTime.of(2012, 2, 29, 2, 7), MinguoChronology.INSTANCE.date(MinguoEra.ROC, 2012 - YDIFF, 2, 29), LocalTime.of(2, 7), null}, {ZonedDateTime.of(2012, 2, 29, 2, 7, 1, 1, ZONE_PARIS), MinguoChronology.INSTANCE.date(MinguoEra.ROC, 2012 - YDIFF, 2, 29), LocalTime.of(2, 7, 1, 1), null}, {OffsetDateTime.of(2012, 2, 29, 2, 7, 1, 1, OFFSET_PTWO), MinguoChronology.INSTANCE.date(MinguoEra.ROC, 2012 - YDIFF, 2, 29), LocalTime.of(2, 7, 1, 1), null}, {JapaneseDate.of(2012, 2, 29), null, null, DateTimeException.class}, {ThaiBuddhistDate.of(2012 + 543, 2, 29), null, null, DateTimeException.class}, {LocalDate.of(2012, 2, 29), null, null, DateTimeException.class}, {LocalTime.of(20, 30, 29, 0), null, null, DateTimeException.class}, }; }
Example #29
Source File: TestUmmAlQuraChronology.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
@DataProvider(name="localDateTime") Object[][] data_localDateTime() { return new Object[][] { {LocalDateTime.of(2012, 2, 29, 2, 7), HijrahChronology.INSTANCE.date(1433, 4, 7), LocalTime.of(2, 7), null}, {ZonedDateTime.of(2012, 2, 29, 2, 7, 1, 1, ZONE_RIYADH), HijrahChronology.INSTANCE.date(1433, 4, 7), LocalTime.of(2, 7, 1, 1), null}, {OffsetDateTime.of(2012, 2, 29, 2, 7, 1, 1, OFFSET_PTWO), HijrahChronology.INSTANCE.date(1433, 4, 7), LocalTime.of(2, 7, 1, 1), null}, {JapaneseDate.of(2012, 2, 29), null, null, DateTimeException.class}, {ThaiBuddhistDate.of(2012 + 543, 2, 29), null, null, DateTimeException.class}, {LocalDate.of(2012, 2, 29), null, null, DateTimeException.class}, {LocalTime.of(20, 30, 29, 0), null, null, DateTimeException.class}, }; }
Example #30
Source File: TCKJapaneseChronology.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
@Test public void test_getLong() { JapaneseDate base = JapaneseChronology.INSTANCE.date(JapaneseEra.SHOWA, 63, 6, 30); assertEquals(base.getLong(ERA), JapaneseEra.SHOWA.getValue()); assertEquals(base.getLong(YEAR), 1988L); assertEquals(base.getLong(YEAR_OF_ERA), 63L); assertEquals(base.getLong(MONTH_OF_YEAR), 6L); assertEquals(base.getLong(DAY_OF_MONTH), 30L); }