当前位置: 首页>>代码示例>>Java>>正文


Java JapaneseEra.values方法代码示例

本文整理汇总了Java中java.time.chrono.JapaneseEra.values方法的典型用法代码示例。如果您正苦于以下问题:Java JapaneseEra.values方法的具体用法?Java JapaneseEra.values怎么用?Java JapaneseEra.values使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.time.chrono.JapaneseEra的用法示例。


在下文中一共展示了JapaneseEra.values方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: test_getDayOfYear

import java.time.chrono.JapaneseEra; //导入方法依赖的package包/类
@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);
        }
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:17,代码来源:TCKJapaneseChronology.java

示例2: test_dayOfYearVsCalendar

import java.time.chrono.JapaneseEra; //导入方法依赖的package包/类
@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);
        }
    }

}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:24,代码来源:TestJapaneseChronoImpl.java

示例3: test_range

import java.time.chrono.JapaneseEra; //导入方法依赖的package包/类
@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);
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:11,代码来源:TCKJapaneseEra.java

示例4: test_JapaneseEra_values

import java.time.chrono.JapaneseEra; //导入方法依赖的package包/类
@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");
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:12,代码来源:TCKJapaneseChronology.java

示例5: data_resolve_styleByEra

import java.time.chrono.JapaneseEra; //导入方法依赖的package包/类
@DataProvider(name = "resolve_styleByEra")
Object[][] data_resolve_styleByEra() {
    Object[][] result = new Object[ResolverStyle.values().length * JapaneseEra.values().length][];
    int i = 0;
    for (ResolverStyle style : ResolverStyle.values()) {
        for (JapaneseEra era : JapaneseEra.values()) {
            result[i++] = new Object[] {style, era};
        }
    }
    return result;
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:12,代码来源:TCKJapaneseChronology.java

示例6: test_JapaneseErasSerialization

import java.time.chrono.JapaneseEra; //导入方法依赖的package包/类
@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);
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:15,代码来源:TCKEraSerialization.java


注:本文中的java.time.chrono.JapaneseEra.values方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。