java.time.chrono.IsoEra Java Examples

The following examples show how to use java.time.chrono.IsoEra. 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: TCKIsoChronology.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
@DataProvider(name = "era_epochSecond_dataProvider")
Object[][] data_era_epochSecond() {
    return new Object[][] {
            {IsoEra.CE, 2008, 3, 3, 1, 2, 2, OFFSET_P0100},
            {IsoEra.CE, 2008, 3, 3, 1, 2, 2, OFFSET_M0100},
            {IsoEra.CE, 2008, 2, 28, 1, 2, 2, OFFSET_P0100},
            {IsoEra.CE, 2009, 3, 3, 1, 2, 2, OFFSET_P0100},
            {IsoEra.CE, 2009, 3, 3, 1, 2, 2, OFFSET_M0100},
            {IsoEra.CE, 2009, 2, 28, 1, 2, 2, OFFSET_P0100},
            {IsoEra.CE, 1968, 3, 3, 1, 2, 2, OFFSET_P0100},
            {IsoEra.CE, 1968, 3, 3, 1, 2, 2, OFFSET_M0100},
            {IsoEra.CE, 1968, 2, 28, 1, 2, 2, OFFSET_P0100},
            {IsoEra.CE, 1969, 3, 3 , 1, 2, 2, OFFSET_P0100},
            {IsoEra.CE, 1969, 3, 3, 1, 2, 2, OFFSET_M0100},
            {IsoEra.CE, 1969, 2, 28, 1, 2, 2, OFFSET_P0100},
            {IsoEra.CE, 1970, 1, 1, 1, 2, 2, OFFSET_P0100},
            {IsoEra.CE, 1970, 1, 1, 1, 2, 2, OFFSET_M0100},
            {IsoEra.BCE, 5, 3, 3 , 1, 2, 2, OFFSET_P0100},
            {IsoEra.BCE, 2, 3, 3 , 1, 2, 2, OFFSET_P0100},
    };
}
 
Example #2
Source File: TCKYear.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
@Test
public void test_with() {
    Year base = Year.of(5);
    Year result = base.with(ChronoField.ERA, 0);
    assertEquals(result, base.with(IsoEra.of(0)));

    int prolepticYear = IsoChronology.INSTANCE.prolepticYear(IsoEra.of(0), 5);
    assertEquals(result.get(ChronoField.ERA), 0);
    assertEquals(result.get(ChronoField.YEAR), prolepticYear);
    assertEquals(result.get(ChronoField.YEAR_OF_ERA), 5);

    result = base.with(ChronoField.YEAR, 10);
    assertEquals(result.get(ChronoField.ERA), base.get(ChronoField.ERA));
    assertEquals(result.get(ChronoField.YEAR), 10);
    assertEquals(result.get(ChronoField.YEAR_OF_ERA), 10);

    result = base.with(ChronoField.YEAR_OF_ERA, 20);
    assertEquals(result.get(ChronoField.ERA), base.get(ChronoField.ERA));
    assertEquals(result.get(ChronoField.YEAR), 20);
    assertEquals(result.get(ChronoField.YEAR_OF_ERA), 20);
}
 
Example #3
Source File: TCKYear.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
@Test
public void test_with() {
    Year base = Year.of(5);
    Year result = base.with(ChronoField.ERA, 0);
    assertEquals(result, base.with(IsoEra.of(0)));

    int prolepticYear = IsoChronology.INSTANCE.prolepticYear(IsoEra.of(0), 5);
    assertEquals(result.get(ChronoField.ERA), 0);
    assertEquals(result.get(ChronoField.YEAR), prolepticYear);
    assertEquals(result.get(ChronoField.YEAR_OF_ERA), 5);

    result = base.with(ChronoField.YEAR, 10);
    assertEquals(result.get(ChronoField.ERA), base.get(ChronoField.ERA));
    assertEquals(result.get(ChronoField.YEAR), 10);
    assertEquals(result.get(ChronoField.YEAR_OF_ERA), 10);

    result = base.with(ChronoField.YEAR_OF_ERA, 20);
    assertEquals(result.get(ChronoField.ERA), base.get(ChronoField.ERA));
    assertEquals(result.get(ChronoField.YEAR), 20);
    assertEquals(result.get(ChronoField.YEAR_OF_ERA), 20);
}
 
Example #4
Source File: TCKYear.java    From j2objc with Apache License 2.0 6 votes vote down vote up
@Test
public void test_with() {
    Year base = Year.of(5);
    Year result = base.with(ChronoField.ERA, 0);
    assertEquals(result, base.with(IsoEra.of(0)));

    int prolepticYear = IsoChronology.INSTANCE.prolepticYear(IsoEra.of(0), 5);
    assertEquals(result.get(ChronoField.ERA), 0);
    assertEquals(result.get(ChronoField.YEAR), prolepticYear);
    assertEquals(result.get(ChronoField.YEAR_OF_ERA), 5);

    result = base.with(ChronoField.YEAR, 10);
    assertEquals(result.get(ChronoField.ERA), base.get(ChronoField.ERA));
    assertEquals(result.get(ChronoField.YEAR), 10);
    assertEquals(result.get(ChronoField.YEAR_OF_ERA), 10);

    result = base.with(ChronoField.YEAR_OF_ERA, 20);
    assertEquals(result.get(ChronoField.ERA), base.get(ChronoField.ERA));
    assertEquals(result.get(ChronoField.YEAR), 20);
    assertEquals(result.get(ChronoField.YEAR_OF_ERA), 20);
}
 
Example #5
Source File: TCKYear.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
@Test
public void test_with() {
    Year base = Year.of(5);
    Year result = base.with(ChronoField.ERA, 0);
    assertEquals(result, base.with(IsoEra.of(0)));

    int prolepticYear = IsoChronology.INSTANCE.prolepticYear(IsoEra.of(0), 5);
    assertEquals(result.get(ChronoField.ERA), 0);
    assertEquals(result.get(ChronoField.YEAR), prolepticYear);
    assertEquals(result.get(ChronoField.YEAR_OF_ERA), 5);

    result = base.with(ChronoField.YEAR, 10);
    assertEquals(result.get(ChronoField.ERA), base.get(ChronoField.ERA));
    assertEquals(result.get(ChronoField.YEAR), 10);
    assertEquals(result.get(ChronoField.YEAR_OF_ERA), 10);

    result = base.with(ChronoField.YEAR_OF_ERA, 20);
    assertEquals(result.get(ChronoField.ERA), base.get(ChronoField.ERA));
    assertEquals(result.get(ChronoField.YEAR), 20);
    assertEquals(result.get(ChronoField.YEAR_OF_ERA), 20);
}
 
Example #6
Source File: TCKYear.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
@Test
public void test_with() {
    Year base = Year.of(5);
    Year result = base.with(ChronoField.ERA, 0);
    assertEquals(result, base.with(IsoEra.of(0)));

    int prolepticYear = IsoChronology.INSTANCE.prolepticYear(IsoEra.of(0), 5);
    assertEquals(result.get(ChronoField.ERA), 0);
    assertEquals(result.get(ChronoField.YEAR), prolepticYear);
    assertEquals(result.get(ChronoField.YEAR_OF_ERA), 5);

    result = base.with(ChronoField.YEAR, 10);
    assertEquals(result.get(ChronoField.ERA), base.get(ChronoField.ERA));
    assertEquals(result.get(ChronoField.YEAR), 10);
    assertEquals(result.get(ChronoField.YEAR_OF_ERA), 10);

    result = base.with(ChronoField.YEAR_OF_ERA, 20);
    assertEquals(result.get(ChronoField.ERA), base.get(ChronoField.ERA));
    assertEquals(result.get(ChronoField.YEAR), 20);
    assertEquals(result.get(ChronoField.YEAR_OF_ERA), 20);
}
 
Example #7
Source File: TCKYear.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
@Test
public void test_with() {
    Year base = Year.of(5);
    Year result = base.with(ChronoField.ERA, 0);
    assertEquals(result, base.with(IsoEra.of(0)));

    int prolepticYear = IsoChronology.INSTANCE.prolepticYear(IsoEra.of(0), 5);
    assertEquals(result.get(ChronoField.ERA), 0);
    assertEquals(result.get(ChronoField.YEAR), prolepticYear);
    assertEquals(result.get(ChronoField.YEAR_OF_ERA), 5);

    result = base.with(ChronoField.YEAR, 10);
    assertEquals(result.get(ChronoField.ERA), base.get(ChronoField.ERA));
    assertEquals(result.get(ChronoField.YEAR), 10);
    assertEquals(result.get(ChronoField.YEAR_OF_ERA), 10);

    result = base.with(ChronoField.YEAR_OF_ERA, 20);
    assertEquals(result.get(ChronoField.ERA), base.get(ChronoField.ERA));
    assertEquals(result.get(ChronoField.YEAR), 20);
    assertEquals(result.get(ChronoField.YEAR_OF_ERA), 20);
}
 
Example #8
Source File: TCKYear.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
@Test
public void test_with() {
    Year base = Year.of(5);
    Year result = base.with(ChronoField.ERA, 0);
    assertEquals(result, base.with(IsoEra.of(0)));

    int prolepticYear = IsoChronology.INSTANCE.prolepticYear(IsoEra.of(0), 5);
    assertEquals(result.get(ChronoField.ERA), 0);
    assertEquals(result.get(ChronoField.YEAR), prolepticYear);
    assertEquals(result.get(ChronoField.YEAR_OF_ERA), 5);

    result = base.with(ChronoField.YEAR, 10);
    assertEquals(result.get(ChronoField.ERA), base.get(ChronoField.ERA));
    assertEquals(result.get(ChronoField.YEAR), 10);
    assertEquals(result.get(ChronoField.YEAR_OF_ERA), 10);

    result = base.with(ChronoField.YEAR_OF_ERA, 20);
    assertEquals(result.get(ChronoField.ERA), base.get(ChronoField.ERA));
    assertEquals(result.get(ChronoField.YEAR), 20);
    assertEquals(result.get(ChronoField.YEAR_OF_ERA), 20);
}
 
Example #9
Source File: YearMonthTest.java    From j2objc with Apache License 2.0 6 votes vote down vote up
@Test
public void test_with_TemporalField_long() {
    YearMonth ym = YearMonth.of(2000, Month.JANUARY);
    // -1999 is actually 2000 BCE (and 0 is 1 BCE).
    YearMonth bceYm = YearMonth.of(-1999, Month.JANUARY);

    assertEquals(YearMonth.of(1000, Month.JANUARY), ym.with(ChronoField.YEAR, 1000));
    assertEquals(YearMonth.of(-1, Month.JANUARY), ym.with(ChronoField.YEAR, -1));
    assertEquals(YearMonth.of(2000, Month.FEBRUARY), ym.with(ChronoField.MONTH_OF_YEAR, 2));
    assertEquals(YearMonth.of(-1999, Month.DECEMBER),
            bceYm.with(ChronoField.MONTH_OF_YEAR, 12));
    assertSame(ym, ym.with(ChronoField.ERA, IsoEra.CE.getValue()));
    assertSame(bceYm, bceYm.with(ChronoField.ERA, IsoEra.BCE.getValue()));

    assertEquals(bceYm, ym.with(ChronoField.ERA, IsoEra.BCE.getValue()));
    assertEquals(ym, bceYm.with(ChronoField.ERA, IsoEra.CE.getValue()));
    assertEquals(YearMonth.of(1, Month.JANUARY), ym.with(ChronoField.YEAR_OF_ERA, 1));
    // Proleptic year 0 is 1 BCE.
    assertEquals(YearMonth.of(0, Month.JANUARY), bceYm.with(ChronoField.YEAR_OF_ERA, 1));
    assertEquals(YearMonth.of(0, Month.JANUARY), ym.with(ChronoField.PROLEPTIC_MONTH, 0));
    assertEquals(YearMonth.of(Year.MAX_VALUE, Month.DECEMBER), ym.with(ChronoField.PROLEPTIC_MONTH, Year.MAX_VALUE * 12L + 11));
    assertEquals(YearMonth.of(Year.MIN_VALUE, Month.JANUARY), ym.with(ChronoField.PROLEPTIC_MONTH, Year.MIN_VALUE * 12L));
}
 
Example #10
Source File: TCKYear.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
@Test
public void test_with() {
    Year base = Year.of(5);
    Year result = base.with(ChronoField.ERA, 0);
    assertEquals(result, base.with(IsoEra.of(0)));

    int prolepticYear = IsoChronology.INSTANCE.prolepticYear(IsoEra.of(0), 5);
    assertEquals(result.get(ChronoField.ERA), 0);
    assertEquals(result.get(ChronoField.YEAR), prolepticYear);
    assertEquals(result.get(ChronoField.YEAR_OF_ERA), 5);

    result = base.with(ChronoField.YEAR, 10);
    assertEquals(result.get(ChronoField.ERA), base.get(ChronoField.ERA));
    assertEquals(result.get(ChronoField.YEAR), 10);
    assertEquals(result.get(ChronoField.YEAR_OF_ERA), 10);

    result = base.with(ChronoField.YEAR_OF_ERA, 20);
    assertEquals(result.get(ChronoField.ERA), base.get(ChronoField.ERA));
    assertEquals(result.get(ChronoField.YEAR), 20);
    assertEquals(result.get(ChronoField.YEAR_OF_ERA), 20);
}
 
Example #11
Source File: TCKYear.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
@Test
public void test_with() {
    Year base = Year.of(5);
    Year result = base.with(ChronoField.ERA, 0);
    assertEquals(result, base.with(IsoEra.of(0)));

    int prolepticYear = IsoChronology.INSTANCE.prolepticYear(IsoEra.of(0), 5);
    assertEquals(result.get(ChronoField.ERA), 0);
    assertEquals(result.get(ChronoField.YEAR), prolepticYear);
    assertEquals(result.get(ChronoField.YEAR_OF_ERA), 5);

    result = base.with(ChronoField.YEAR, 10);
    assertEquals(result.get(ChronoField.ERA), base.get(ChronoField.ERA));
    assertEquals(result.get(ChronoField.YEAR), 10);
    assertEquals(result.get(ChronoField.YEAR_OF_ERA), 10);

    result = base.with(ChronoField.YEAR_OF_ERA, 20);
    assertEquals(result.get(ChronoField.ERA), base.get(ChronoField.ERA));
    assertEquals(result.get(ChronoField.YEAR), 20);
    assertEquals(result.get(ChronoField.YEAR_OF_ERA), 20);
}
 
Example #12
Source File: TCKYear.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
@Test
public void test_with() {
    Year base = Year.of(5);
    Year result = base.with(ChronoField.ERA, 0);
    assertEquals(result, base.with(IsoEra.of(0)));

    int prolepticYear = IsoChronology.INSTANCE.prolepticYear(IsoEra.of(0), 5);
    assertEquals(result.get(ChronoField.ERA), 0);
    assertEquals(result.get(ChronoField.YEAR), prolepticYear);
    assertEquals(result.get(ChronoField.YEAR_OF_ERA), 5);

    result = base.with(ChronoField.YEAR, 10);
    assertEquals(result.get(ChronoField.ERA), base.get(ChronoField.ERA));
    assertEquals(result.get(ChronoField.YEAR), 10);
    assertEquals(result.get(ChronoField.YEAR_OF_ERA), 10);

    result = base.with(ChronoField.YEAR_OF_ERA, 20);
    assertEquals(result.get(ChronoField.ERA), base.get(ChronoField.ERA));
    assertEquals(result.get(ChronoField.YEAR), 20);
    assertEquals(result.get(ChronoField.YEAR_OF_ERA), 20);
}
 
Example #13
Source File: TCKYear.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
@Test
public void test_with() {
    Year base = Year.of(5);
    Year result = base.with(ChronoField.ERA, 0);
    assertEquals(result, base.with(IsoEra.of(0)));

    int prolepticYear = IsoChronology.INSTANCE.prolepticYear(IsoEra.of(0), 5);
    assertEquals(result.get(ChronoField.ERA), 0);
    assertEquals(result.get(ChronoField.YEAR), prolepticYear);
    assertEquals(result.get(ChronoField.YEAR_OF_ERA), 5);

    result = base.with(ChronoField.YEAR, 10);
    assertEquals(result.get(ChronoField.ERA), base.get(ChronoField.ERA));
    assertEquals(result.get(ChronoField.YEAR), 10);
    assertEquals(result.get(ChronoField.YEAR_OF_ERA), 10);

    result = base.with(ChronoField.YEAR_OF_ERA, 20);
    assertEquals(result.get(ChronoField.ERA), base.get(ChronoField.ERA));
    assertEquals(result.get(ChronoField.YEAR), 20);
    assertEquals(result.get(ChronoField.YEAR_OF_ERA), 20);
}
 
Example #14
Source File: TCKYear.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
@Test
public void test_with() {
    Year base = Year.of(5);
    Year result = base.with(ChronoField.ERA, 0);
    assertEquals(result, base.with(IsoEra.of(0)));

    int prolepticYear = IsoChronology.INSTANCE.prolepticYear(IsoEra.of(0), 5);
    assertEquals(result.get(ChronoField.ERA), 0);
    assertEquals(result.get(ChronoField.YEAR), prolepticYear);
    assertEquals(result.get(ChronoField.YEAR_OF_ERA), 5);

    result = base.with(ChronoField.YEAR, 10);
    assertEquals(result.get(ChronoField.ERA), base.get(ChronoField.ERA));
    assertEquals(result.get(ChronoField.YEAR), 10);
    assertEquals(result.get(ChronoField.YEAR_OF_ERA), 10);

    result = base.with(ChronoField.YEAR_OF_ERA, 20);
    assertEquals(result.get(ChronoField.ERA), base.get(ChronoField.ERA));
    assertEquals(result.get(ChronoField.YEAR), 20);
    assertEquals(result.get(ChronoField.YEAR_OF_ERA), 20);
}
 
Example #15
Source File: TCKChronology.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void test_IsoChronology_dateYearDay() {
    Chronology chrono = Chronology.of("ISO");
    ChronoLocalDate date1 = chrono.dateYearDay(IsoEra.CE, 5, 60);
    ChronoLocalDate date2 = chrono.date(IsoEra.CE, 5, 3, 1);
    assertEquals(date1, IsoChronology.INSTANCE.dateYearDay(IsoEra.CE, 5, 60));
    assertEquals(date2, IsoChronology.INSTANCE.dateYearDay(IsoEra.CE, 5, 60));
}
 
Example #16
Source File: TCKEraSerialization.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
@DataProvider(name = "Eras")
Era[][] data_of_calendars() {
    return new Era[][] {
                {HijrahEra.AH},
                {IsoEra.BCE},
                {IsoEra.CE},
                {MinguoEra.BEFORE_ROC},
                {MinguoEra.ROC},
                {ThaiBuddhistEra.BEFORE_BE},
                {ThaiBuddhistEra.BE},
    };
}
 
Example #17
Source File: TCKEraSerialization.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
@DataProvider(name = "Eras")
Era[][] data_of_calendars() {
    return new Era[][] {
                {HijrahEra.AH},
                {IsoEra.BCE},
                {IsoEra.CE},
                {MinguoEra.BEFORE_ROC},
                {MinguoEra.ROC},
                {ThaiBuddhistEra.BEFORE_BE},
                {ThaiBuddhistEra.BE},
    };
}
 
Example #18
Source File: TestIsoChronology.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void test_date_withEra() {
    int year = 5;
    int month = 5;
    int dayOfMonth = 5;
    LocalDate test = IsoChronology.INSTANCE.date(IsoEra.BCE, year, month, dayOfMonth);
    assertEquals(test.getEra(), IsoEra.BCE);
    assertEquals(test.get(ChronoField.YEAR_OF_ERA), year);
    assertEquals(test.get(ChronoField.MONTH_OF_YEAR), month);
    assertEquals(test.get(ChronoField.DAY_OF_MONTH), dayOfMonth);

    assertEquals(test.get(YEAR), 1 + (-1 * year));
    assertEquals(test.get(ERA), 0);
    assertEquals(test.get(YEAR_OF_ERA), year);
}
 
Example #19
Source File: TCKIsoEra.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
@DataProvider(name = "IsoEras")
Object[][] data_of_eras() {
    return new Object[][] {
                {IsoEra.BCE, "BCE", 0},
                {IsoEra.CE, "CE", 1},
    };
}
 
Example #20
Source File: TCKEraSerialization.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
@DataProvider(name = "Eras")
Era[][] data_of_calendars() {
    return new Era[][] {
                {HijrahEra.AH},
                {IsoEra.BCE},
                {IsoEra.CE},
                {MinguoEra.BEFORE_ROC},
                {MinguoEra.ROC},
                {ThaiBuddhistEra.BEFORE_BE},
                {ThaiBuddhistEra.BE},
    };
}
 
Example #21
Source File: TestIsoChronology.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void test_date_withEra() {
    int year = 5;
    int month = 5;
    int dayOfMonth = 5;
    LocalDate test = IsoChronology.INSTANCE.date(IsoEra.BCE, year, month, dayOfMonth);
    assertEquals(test.getEra(), IsoEra.BCE);
    assertEquals(test.get(ChronoField.YEAR_OF_ERA), year);
    assertEquals(test.get(ChronoField.MONTH_OF_YEAR), month);
    assertEquals(test.get(ChronoField.DAY_OF_MONTH), dayOfMonth);

    assertEquals(test.get(YEAR), 1 + (-1 * year));
    assertEquals(test.get(ERA), 0);
    assertEquals(test.get(YEAR_OF_ERA), year);
}
 
Example #22
Source File: TCKIsoEra.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
@DataProvider(name = "IsoEras")
Object[][] data_of_eras() {
    return new Object[][] {
                {IsoEra.BCE, "BCE", 0},
                {IsoEra.CE, "CE", 1},
    };
}
 
Example #23
Source File: TCKIsoEra.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
@DataProvider(name = "IsoEras")
Object[][] data_of_eras() {
    return new Object[][] {
                {IsoEra.BCE, "BCE", 0},
                {IsoEra.CE, "CE", 1},
    };
}
 
Example #24
Source File: TCKEraSerialization.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
@DataProvider(name = "Eras")
Era[][] data_of_calendars() {
    return new Era[][] {
                {HijrahEra.AH},
                {IsoEra.BCE},
                {IsoEra.CE},
                {MinguoEra.BEFORE_ROC},
                {MinguoEra.ROC},
                {ThaiBuddhistEra.BEFORE_BE},
                {ThaiBuddhistEra.BE},
    };
}
 
Example #25
Source File: TCKIsoEra.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
@DataProvider(name = "IsoEras")
Object[][] data_of_eras() {
    return new Object[][] {
                {IsoEra.BCE, "BCE", 0},
                {IsoEra.CE, "CE", 1},
    };
}
 
Example #26
Source File: TCKIsoEra.java    From j2objc with Apache License 2.0 5 votes vote down vote up
@Test()
@UseDataProvider("data_of_eras")
public void test_valueOf(IsoEra era , String eraName, int eraValue) {
    assertEquals(era.getValue(), eraValue);
    assertEquals(IsoEra.of(eraValue), era);
    assertEquals(IsoEra.valueOf(eraName), era);
}
 
Example #27
Source File: TestIsoChronology.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void test_date_withEra() {
    int year = 5;
    int month = 5;
    int dayOfMonth = 5;
    LocalDate test = IsoChronology.INSTANCE.date(IsoEra.BCE, year, month, dayOfMonth);
    assertEquals(test.getEra(), IsoEra.BCE);
    assertEquals(test.get(ChronoField.YEAR_OF_ERA), year);
    assertEquals(test.get(ChronoField.MONTH_OF_YEAR), month);
    assertEquals(test.get(ChronoField.DAY_OF_MONTH), dayOfMonth);

    assertEquals(test.get(YEAR), 1 + (-1 * year));
    assertEquals(test.get(ERA), 0);
    assertEquals(test.get(YEAR_OF_ERA), year);
}
 
Example #28
Source File: TCKEraSerialization.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@DataProvider(name = "Eras")
Era[][] data_of_calendars() {
    return new Era[][] {
                {HijrahEra.AH},
                {IsoEra.BCE},
                {IsoEra.CE},
                {MinguoEra.BEFORE_ROC},
                {MinguoEra.ROC},
                {ThaiBuddhistEra.BEFORE_BE},
                {ThaiBuddhistEra.BE},
    };
}
 
Example #29
Source File: TCKEraSerialization.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
@DataProvider(name = "Eras")
Era[][] data_of_calendars() {
    return new Era[][] {
                {HijrahEra.AH},
                {IsoEra.BCE},
                {IsoEra.CE},
                {MinguoEra.BEFORE_ROC},
                {MinguoEra.ROC},
                {ThaiBuddhistEra.BEFORE_BE},
                {ThaiBuddhistEra.BE},
    };
}
 
Example #30
Source File: TestIsoChronology.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void test_date_withEra() {
    int year = 5;
    int month = 5;
    int dayOfMonth = 5;
    LocalDate test = IsoChronology.INSTANCE.date(IsoEra.BCE, year, month, dayOfMonth);
    assertEquals(test.getEra(), IsoEra.BCE);
    assertEquals(test.get(ChronoField.YEAR_OF_ERA), year);
    assertEquals(test.get(ChronoField.MONTH_OF_YEAR), month);
    assertEquals(test.get(ChronoField.DAY_OF_MONTH), dayOfMonth);

    assertEquals(test.get(YEAR), 1 + (-1 * year));
    assertEquals(test.get(ERA), 0);
    assertEquals(test.get(YEAR_OF_ERA), year);
}