Java Code Examples for java.time.chrono.JapaneseEra#valueOf()

The following examples show how to use java.time.chrono.JapaneseEra#valueOf() . 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 openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
@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 2
Source File: TCKJapaneseChronology.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
@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 3
Source File: TCKJapaneseChronology.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
@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 4
Source File: JapanEraNameCompatTest.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
@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 5
Source File: TCKJapaneseChronology.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
@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 6
Source File: TCKJapaneseChronology.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
@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 7
Source File: TCKJapaneseChronology.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
@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 8
Source File: TCKJapaneseChronology.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
@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 9
Source File: TCKJapaneseChronology.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
@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 10
Source File: TCKJapaneseChronology.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@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 11
Source File: TCKJapaneseChronology.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
@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 12
Source File: JapaneseEraConverter.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@Override
public JapaneseEra fromString(final String str) {
    if (str == null) {
        return null;
    }
    try {
        return JapaneseEra.valueOf(str);
    } catch (final IllegalArgumentException e) {
        final ConversionException exception = new ConversionException("Cannot parse value as Japanese era", e);
        exception.add("value", str);
        throw exception;
    }
}
 
Example 13
Source File: JapanEraNameCompatTest.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
@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 14
Source File: TCKJapaneseChronology.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
@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 15
Source File: TCKJapaneseChronology.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
@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 16
Source File: JapanEraNameCompatTest.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
@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 17
Source File: TCKJapaneseChronology.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
@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 18
Source File: JapanEraNameCompatTest.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
@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 19
Source File: JapaneseDateConverter.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
@Override
protected JapaneseEra eraOf(final String id) {
    return JapaneseEra.valueOf(id);
}