Java 类java.time.chrono.MinguoDate 实例源码

项目:jdk8u-jdk    文件:TCKMinguoChronology.java   
@Test
public void test_dateNow(){
    assertEquals(MinguoChronology.INSTANCE.dateNow(), MinguoDate.now()) ;
    assertEquals(MinguoChronology.INSTANCE.dateNow(), MinguoDate.now(ZoneId.systemDefault())) ;
    assertEquals(MinguoChronology.INSTANCE.dateNow(), MinguoDate.now(Clock.systemDefaultZone())) ;
    assertEquals(MinguoChronology.INSTANCE.dateNow(), MinguoDate.now(Clock.systemDefaultZone().getZone())) ;

    assertEquals(MinguoChronology.INSTANCE.dateNow(), MinguoChronology.INSTANCE.dateNow(ZoneId.systemDefault())) ;
    assertEquals(MinguoChronology.INSTANCE.dateNow(), MinguoChronology.INSTANCE.dateNow(Clock.systemDefaultZone())) ;
    assertEquals(MinguoChronology.INSTANCE.dateNow(), MinguoChronology.INSTANCE.dateNow(Clock.systemDefaultZone().getZone())) ;

    ZoneId zoneId = ZoneId.of("Europe/Paris");
    assertEquals(MinguoChronology.INSTANCE.dateNow(zoneId), MinguoChronology.INSTANCE.dateNow(Clock.system(zoneId))) ;
    assertEquals(MinguoChronology.INSTANCE.dateNow(zoneId), MinguoChronology.INSTANCE.dateNow(Clock.system(zoneId).getZone())) ;
    assertEquals(MinguoChronology.INSTANCE.dateNow(zoneId), MinguoDate.now(Clock.system(zoneId))) ;
    assertEquals(MinguoChronology.INSTANCE.dateNow(zoneId), MinguoDate.now(Clock.system(zoneId).getZone())) ;

    assertEquals(MinguoChronology.INSTANCE.dateNow(ZoneId.of(ZoneOffset.UTC.getId())), MinguoChronology.INSTANCE.dateNow(Clock.systemUTC())) ;
}
项目:jdk8u-jdk    文件:TCKMinguoChronology.java   
@SuppressWarnings("unused")
@Test(dataProvider="samples")
public void test_MinguoDate(MinguoDate minguoDate, LocalDate iso) {
    MinguoDate hd = minguoDate;
    ChronoLocalDateTime<MinguoDate> hdt = hd.atTime(LocalTime.NOON);
    ZoneOffset zo = ZoneOffset.ofHours(1);
    ChronoZonedDateTime<MinguoDate> hzdt = hdt.atZone(zo);
    hdt = hdt.plus(1, ChronoUnit.YEARS);
    hdt = hdt.plus(1, ChronoUnit.MONTHS);
    hdt = hdt.plus(1, ChronoUnit.DAYS);
    hdt = hdt.plus(1, ChronoUnit.HOURS);
    hdt = hdt.plus(1, ChronoUnit.MINUTES);
    hdt = hdt.plus(1, ChronoUnit.SECONDS);
    hdt = hdt.plus(1, ChronoUnit.NANOS);
    ChronoLocalDateTime<MinguoDate> a2 = hzdt.toLocalDateTime();
    MinguoDate a3 = a2.toLocalDate();
    MinguoDate a5 = hzdt.toLocalDate();
    //System.out.printf(" d: %s, dt: %s; odt: %s; zodt: %s; a4: %s%n", date, hdt, hodt, hzdt, a5);
}
项目:jdk8u-jdk    文件:TCKMinguoChronology.java   
@Test(dataProvider = "resolve_yearOfEra")
public void test_resolve_yearOfEra(ResolverStyle style, Integer e, Integer yoe, Integer y, ChronoField field, Integer expected) {
    Map<TemporalField, Long> fieldValues = new HashMap<>();
    if (e != null) {
        fieldValues.put(ChronoField.ERA, (long) e);
    }
    if (yoe != null) {
        fieldValues.put(ChronoField.YEAR_OF_ERA, (long) yoe);
    }
    if (y != null) {
        fieldValues.put(ChronoField.YEAR, (long) y);
    }
    if (field != null) {
        MinguoDate date = MinguoChronology.INSTANCE.resolveDate(fieldValues, style);
        assertEquals(date, null);
        assertEquals(fieldValues.get(field), (Long) expected.longValue());
        assertEquals(fieldValues.size(), 1);
    } else {
        try {
            MinguoChronology.INSTANCE.resolveDate(fieldValues, style);
            fail("Should have failed");
        } catch (DateTimeException ex) {
            // expected
        }
    }
}
项目:jdk8u-jdk    文件:TCKMinguoChronology.java   
@Test(dataProvider = "resolve_ymd")
public void test_resolve_ymd_strict(int y, int m, int d, MinguoDate 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) {
        MinguoDate date = MinguoChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.STRICT);
        assertEquals(date, expected);
        assertEquals(fieldValues.size(), 0);
    } else {
        try {
            MinguoChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.STRICT);
            fail("Should have failed");
        } catch (DateTimeException ex) {
            // expected
        }
    }
}
项目:jdk8u-jdk    文件:TCKMinguoChronology.java   
@Test(dataProvider = "resolve_yd")
public void test_resolve_yd_smart(int y, int d, MinguoDate 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) {
        MinguoDate date = MinguoChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.SMART);
        assertEquals(date, expected);
        assertEquals(fieldValues.size(), 0);
    } else {
        try {
            MinguoChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.SMART);
            fail("Should have failed");
        } catch (DateTimeException ex) {
            // expected
        }
    }
}
项目:jdk8u-jdk    文件:TCKMinguoChronology.java   
@Test(dataProvider = "resolve_yd")
public void test_resolve_yd_strict(int y, int d, MinguoDate 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) {
        MinguoDate date = MinguoChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.STRICT);
        assertEquals(date, expected);
        assertEquals(fieldValues.size(), 0);
    } else {
        try {
            MinguoChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.STRICT);
            fail("Should have failed");
        } catch (DateTimeException ex) {
            // expected
        }
    }
}
项目:jdk8u-jdk    文件:TCKMinguoChronology.java   
@Test(dataProvider = "resolve_ymaa")
public void test_resolve_ymaa_smart(int y, int m, int w, int d, MinguoDate expected, boolean 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.ALIGNED_WEEK_OF_MONTH, (long) w);
    fieldValues.put(ChronoField.ALIGNED_DAY_OF_WEEK_IN_MONTH, (long) d);
    if (smart) {
        MinguoDate date = MinguoChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.SMART);
        assertEquals(date, expected);
        assertEquals(fieldValues.size(), 0);
    } else {
        try {
            MinguoChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.SMART);
            fail("Should have failed");
        } catch (DateTimeException ex) {
            // expected
        }
    }
}
项目:jdk8u-jdk    文件:TCKMinguoChronology.java   
@Test(dataProvider = "resolve_ymaa")
public void test_resolve_ymaa_strict(int y, int m, int w, int d, MinguoDate expected, boolean 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.ALIGNED_WEEK_OF_MONTH, (long) w);
    fieldValues.put(ChronoField.ALIGNED_DAY_OF_WEEK_IN_MONTH, (long) d);
    if (strict) {
        MinguoDate date = MinguoChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.STRICT);
        assertEquals(date, expected);
        assertEquals(fieldValues.size(), 0);
    } else {
        try {
            MinguoChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.STRICT);
            fail("Should have failed");
        } catch (DateTimeException ex) {
            // expected
        }
    }
}
项目:jdk8u-jdk    文件:TestReducedPrinter.java   
public void test_minguoChrono_fixedWidth() throws Exception {
    // ISO 2021 is Minguo 110
    DateTimeFormatter f = getFormatterBaseDate(YEAR, 2, 2, 2021);
    MinguoDate date = MinguoDate.of(109, 6, 30);
    assertEquals(f.format(date), "09");
    date = MinguoDate.of(110, 6, 30);
    assertEquals(f.format(date), "10");
    date = MinguoDate.of(199, 6, 30);
    assertEquals(f.format(date), "99");
    date = MinguoDate.of(200, 6, 30);
    assertEquals(f.format(date), "00");
    date = MinguoDate.of(209, 6, 30);
    assertEquals(f.format(date), "09");
    date = MinguoDate.of(210, 6, 30);
    assertEquals(f.format(date), "10");
}
项目:jdk8u-jdk    文件:TestReducedPrinter.java   
public void test_minguoChrono_extendedWidth() throws Exception {
    // ISO 2021 is Minguo 110
    DateTimeFormatter f = getFormatterBaseDate(YEAR, 2, 4, 2021);
    MinguoDate date = MinguoDate.of(109, 6, 30);
    assertEquals(f.format(date), "109");
    date = MinguoDate.of(110, 6, 30);
    assertEquals(f.format(date), "10");
    date = MinguoDate.of(199, 6, 30);
    assertEquals(f.format(date), "99");
    date = MinguoDate.of(200, 6, 30);
    assertEquals(f.format(date), "00");
    date = MinguoDate.of(209, 6, 30);
    assertEquals(f.format(date), "09");
    date = MinguoDate.of(210, 6, 30);
    assertEquals(f.format(date), "210");
}
项目:openjdk-jdk10    文件:TCKMinguoChronology.java   
@Test
public void test_dateNow(){
    assertEquals(MinguoChronology.INSTANCE.dateNow(), MinguoDate.now()) ;
    assertEquals(MinguoChronology.INSTANCE.dateNow(), MinguoDate.now(ZoneId.systemDefault())) ;
    assertEquals(MinguoChronology.INSTANCE.dateNow(), MinguoDate.now(Clock.systemDefaultZone())) ;
    assertEquals(MinguoChronology.INSTANCE.dateNow(), MinguoDate.now(Clock.systemDefaultZone().getZone())) ;

    assertEquals(MinguoChronology.INSTANCE.dateNow(), MinguoChronology.INSTANCE.dateNow(ZoneId.systemDefault())) ;
    assertEquals(MinguoChronology.INSTANCE.dateNow(), MinguoChronology.INSTANCE.dateNow(Clock.systemDefaultZone())) ;
    assertEquals(MinguoChronology.INSTANCE.dateNow(), MinguoChronology.INSTANCE.dateNow(Clock.systemDefaultZone().getZone())) ;

    ZoneId zoneId = ZoneId.of("Europe/Paris");
    assertEquals(MinguoChronology.INSTANCE.dateNow(zoneId), MinguoChronology.INSTANCE.dateNow(Clock.system(zoneId))) ;
    assertEquals(MinguoChronology.INSTANCE.dateNow(zoneId), MinguoChronology.INSTANCE.dateNow(Clock.system(zoneId).getZone())) ;
    assertEquals(MinguoChronology.INSTANCE.dateNow(zoneId), MinguoDate.now(Clock.system(zoneId))) ;
    assertEquals(MinguoChronology.INSTANCE.dateNow(zoneId), MinguoDate.now(Clock.system(zoneId).getZone())) ;

    assertEquals(MinguoChronology.INSTANCE.dateNow(ZoneId.of(ZoneOffset.UTC.getId())), MinguoChronology.INSTANCE.dateNow(Clock.systemUTC())) ;
}
项目:openjdk-jdk10    文件:TCKMinguoChronology.java   
@SuppressWarnings("unused")
@Test(dataProvider="samples")
public void test_MinguoDate(MinguoDate minguoDate, LocalDate iso) {
    MinguoDate hd = minguoDate;
    ChronoLocalDateTime<MinguoDate> hdt = hd.atTime(LocalTime.NOON);
    ZoneOffset zo = ZoneOffset.ofHours(1);
    ChronoZonedDateTime<MinguoDate> hzdt = hdt.atZone(zo);
    hdt = hdt.plus(1, ChronoUnit.YEARS);
    hdt = hdt.plus(1, ChronoUnit.MONTHS);
    hdt = hdt.plus(1, ChronoUnit.DAYS);
    hdt = hdt.plus(1, ChronoUnit.HOURS);
    hdt = hdt.plus(1, ChronoUnit.MINUTES);
    hdt = hdt.plus(1, ChronoUnit.SECONDS);
    hdt = hdt.plus(1, ChronoUnit.NANOS);
    ChronoLocalDateTime<MinguoDate> a2 = hzdt.toLocalDateTime();
    MinguoDate a3 = a2.toLocalDate();
    MinguoDate a5 = hzdt.toLocalDate();
    //System.out.printf(" d: %s, dt: %s; odt: %s; zodt: %s; a4: %s%n", date, hdt, hodt, hzdt, a5);
}
项目:openjdk-jdk10    文件:TCKMinguoChronology.java   
@Test(dataProvider = "resolve_yearOfEra")
public void test_resolve_yearOfEra(ResolverStyle style, Integer e, Integer yoe, Integer y, ChronoField field, Integer expected) {
    Map<TemporalField, Long> fieldValues = new HashMap<>();
    if (e != null) {
        fieldValues.put(ChronoField.ERA, (long) e);
    }
    if (yoe != null) {
        fieldValues.put(ChronoField.YEAR_OF_ERA, (long) yoe);
    }
    if (y != null) {
        fieldValues.put(ChronoField.YEAR, (long) y);
    }
    if (field != null) {
        MinguoDate date = MinguoChronology.INSTANCE.resolveDate(fieldValues, style);
        assertEquals(date, null);
        assertEquals(fieldValues.get(field), (Long) expected.longValue());
        assertEquals(fieldValues.size(), 1);
    } else {
        try {
            MinguoChronology.INSTANCE.resolveDate(fieldValues, style);
            fail("Should have failed");
        } catch (DateTimeException ex) {
            // expected
        }
    }
}
项目:openjdk-jdk10    文件:TCKMinguoChronology.java   
@Test(dataProvider = "resolve_ymd")
public void test_resolve_ymd_strict(int y, int m, int d, MinguoDate 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) {
        MinguoDate date = MinguoChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.STRICT);
        assertEquals(date, expected);
        assertEquals(fieldValues.size(), 0);
    } else {
        try {
            MinguoChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.STRICT);
            fail("Should have failed");
        } catch (DateTimeException ex) {
            // expected
        }
    }
}
项目:openjdk-jdk10    文件:TCKMinguoChronology.java   
@Test(dataProvider = "resolve_yd")
public void test_resolve_yd_smart(int y, int d, MinguoDate 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) {
        MinguoDate date = MinguoChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.SMART);
        assertEquals(date, expected);
        assertEquals(fieldValues.size(), 0);
    } else {
        try {
            MinguoChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.SMART);
            fail("Should have failed");
        } catch (DateTimeException ex) {
            // expected
        }
    }
}
项目:openjdk-jdk10    文件:TCKMinguoChronology.java   
@Test(dataProvider = "resolve_yd")
public void test_resolve_yd_strict(int y, int d, MinguoDate 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) {
        MinguoDate date = MinguoChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.STRICT);
        assertEquals(date, expected);
        assertEquals(fieldValues.size(), 0);
    } else {
        try {
            MinguoChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.STRICT);
            fail("Should have failed");
        } catch (DateTimeException ex) {
            // expected
        }
    }
}
项目:openjdk-jdk10    文件:TCKMinguoChronology.java   
@Test(dataProvider = "resolve_ymaa")
public void test_resolve_ymaa_smart(int y, int m, int w, int d, MinguoDate expected, boolean 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.ALIGNED_WEEK_OF_MONTH, (long) w);
    fieldValues.put(ChronoField.ALIGNED_DAY_OF_WEEK_IN_MONTH, (long) d);
    if (smart) {
        MinguoDate date = MinguoChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.SMART);
        assertEquals(date, expected);
        assertEquals(fieldValues.size(), 0);
    } else {
        try {
            MinguoChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.SMART);
            fail("Should have failed");
        } catch (DateTimeException ex) {
            // expected
        }
    }
}
项目:openjdk-jdk10    文件:TCKMinguoChronology.java   
@Test(dataProvider = "resolve_ymaa")
public void test_resolve_ymaa_strict(int y, int m, int w, int d, MinguoDate expected, boolean 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.ALIGNED_WEEK_OF_MONTH, (long) w);
    fieldValues.put(ChronoField.ALIGNED_DAY_OF_WEEK_IN_MONTH, (long) d);
    if (strict) {
        MinguoDate date = MinguoChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.STRICT);
        assertEquals(date, expected);
        assertEquals(fieldValues.size(), 0);
    } else {
        try {
            MinguoChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.STRICT);
            fail("Should have failed");
        } catch (DateTimeException ex) {
            // expected
        }
    }
}
项目:openjdk-jdk10    文件:TestReducedPrinter.java   
public void test_minguoChrono_fixedWidth() throws Exception {
    // ISO 2021 is Minguo 110
    DateTimeFormatter f = getFormatterBaseDate(YEAR, 2, 2, 2021);
    MinguoDate date = MinguoDate.of(109, 6, 30);
    assertEquals(f.format(date), "09");
    date = MinguoDate.of(110, 6, 30);
    assertEquals(f.format(date), "10");
    date = MinguoDate.of(199, 6, 30);
    assertEquals(f.format(date), "99");
    date = MinguoDate.of(200, 6, 30);
    assertEquals(f.format(date), "00");
    date = MinguoDate.of(209, 6, 30);
    assertEquals(f.format(date), "09");
    date = MinguoDate.of(210, 6, 30);
    assertEquals(f.format(date), "10");
}
项目:openjdk-jdk10    文件:TestReducedPrinter.java   
public void test_minguoChrono_extendedWidth() throws Exception {
    // ISO 2021 is Minguo 110
    DateTimeFormatter f = getFormatterBaseDate(YEAR, 2, 4, 2021);
    MinguoDate date = MinguoDate.of(109, 6, 30);
    assertEquals(f.format(date), "109");
    date = MinguoDate.of(110, 6, 30);
    assertEquals(f.format(date), "10");
    date = MinguoDate.of(199, 6, 30);
    assertEquals(f.format(date), "99");
    date = MinguoDate.of(200, 6, 30);
    assertEquals(f.format(date), "00");
    date = MinguoDate.of(209, 6, 30);
    assertEquals(f.format(date), "09");
    date = MinguoDate.of(210, 6, 30);
    assertEquals(f.format(date), "210");
}
项目:openjdk9    文件:TCKMinguoChronology.java   
@Test
public void test_dateNow(){
    assertEquals(MinguoChronology.INSTANCE.dateNow(), MinguoDate.now()) ;
    assertEquals(MinguoChronology.INSTANCE.dateNow(), MinguoDate.now(ZoneId.systemDefault())) ;
    assertEquals(MinguoChronology.INSTANCE.dateNow(), MinguoDate.now(Clock.systemDefaultZone())) ;
    assertEquals(MinguoChronology.INSTANCE.dateNow(), MinguoDate.now(Clock.systemDefaultZone().getZone())) ;

    assertEquals(MinguoChronology.INSTANCE.dateNow(), MinguoChronology.INSTANCE.dateNow(ZoneId.systemDefault())) ;
    assertEquals(MinguoChronology.INSTANCE.dateNow(), MinguoChronology.INSTANCE.dateNow(Clock.systemDefaultZone())) ;
    assertEquals(MinguoChronology.INSTANCE.dateNow(), MinguoChronology.INSTANCE.dateNow(Clock.systemDefaultZone().getZone())) ;

    ZoneId zoneId = ZoneId.of("Europe/Paris");
    assertEquals(MinguoChronology.INSTANCE.dateNow(zoneId), MinguoChronology.INSTANCE.dateNow(Clock.system(zoneId))) ;
    assertEquals(MinguoChronology.INSTANCE.dateNow(zoneId), MinguoChronology.INSTANCE.dateNow(Clock.system(zoneId).getZone())) ;
    assertEquals(MinguoChronology.INSTANCE.dateNow(zoneId), MinguoDate.now(Clock.system(zoneId))) ;
    assertEquals(MinguoChronology.INSTANCE.dateNow(zoneId), MinguoDate.now(Clock.system(zoneId).getZone())) ;

    assertEquals(MinguoChronology.INSTANCE.dateNow(ZoneId.of(ZoneOffset.UTC.getId())), MinguoChronology.INSTANCE.dateNow(Clock.systemUTC())) ;
}
项目:openjdk9    文件:TCKMinguoChronology.java   
@SuppressWarnings("unused")
@Test(dataProvider="samples")
public void test_MinguoDate(MinguoDate minguoDate, LocalDate iso) {
    MinguoDate hd = minguoDate;
    ChronoLocalDateTime<MinguoDate> hdt = hd.atTime(LocalTime.NOON);
    ZoneOffset zo = ZoneOffset.ofHours(1);
    ChronoZonedDateTime<MinguoDate> hzdt = hdt.atZone(zo);
    hdt = hdt.plus(1, ChronoUnit.YEARS);
    hdt = hdt.plus(1, ChronoUnit.MONTHS);
    hdt = hdt.plus(1, ChronoUnit.DAYS);
    hdt = hdt.plus(1, ChronoUnit.HOURS);
    hdt = hdt.plus(1, ChronoUnit.MINUTES);
    hdt = hdt.plus(1, ChronoUnit.SECONDS);
    hdt = hdt.plus(1, ChronoUnit.NANOS);
    ChronoLocalDateTime<MinguoDate> a2 = hzdt.toLocalDateTime();
    MinguoDate a3 = a2.toLocalDate();
    MinguoDate a5 = hzdt.toLocalDate();
    //System.out.printf(" d: %s, dt: %s; odt: %s; zodt: %s; a4: %s%n", date, hdt, hodt, hzdt, a5);
}
项目:lookaside_java-1.8.0-openjdk    文件:TCKMinguoChronology.java   
@Test(dataProvider = "resolve_yd")
public void test_resolve_yd_smart(int y, int d, MinguoDate 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) {
        MinguoDate date = MinguoChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.SMART);
        assertEquals(date, expected);
        assertEquals(fieldValues.size(), 0);
    } else {
        try {
            MinguoChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.SMART);
            fail("Should have failed");
        } catch (DateTimeException ex) {
            // expected
        }
    }
}
项目:lookaside_java-1.8.0-openjdk    文件:TestReducedPrinter.java   
public void test_minguoChrono_extendedWidth() throws Exception {
    // ISO 2021 is Minguo 110
    DateTimeFormatter f = getFormatterBaseDate(YEAR, 2, 4, 2021);
    MinguoDate date = MinguoDate.of(109, 6, 30);
    assertEquals(f.format(date), "109");
    date = MinguoDate.of(110, 6, 30);
    assertEquals(f.format(date), "10");
    date = MinguoDate.of(199, 6, 30);
    assertEquals(f.format(date), "99");
    date = MinguoDate.of(200, 6, 30);
    assertEquals(f.format(date), "00");
    date = MinguoDate.of(209, 6, 30);
    assertEquals(f.format(date), "09");
    date = MinguoDate.of(210, 6, 30);
    assertEquals(f.format(date), "210");
}
项目:lookaside_java-1.8.0-openjdk    文件:TCKMinguoChronology.java   
@Test(dataProvider = "resolve_yearOfEra")
public void test_resolve_yearOfEra(ResolverStyle style, Integer e, Integer yoe, Integer y, ChronoField field, Integer expected) {
    Map<TemporalField, Long> fieldValues = new HashMap<>();
    if (e != null) {
        fieldValues.put(ChronoField.ERA, (long) e);
    }
    if (yoe != null) {
        fieldValues.put(ChronoField.YEAR_OF_ERA, (long) yoe);
    }
    if (y != null) {
        fieldValues.put(ChronoField.YEAR, (long) y);
    }
    if (field != null) {
        MinguoDate date = MinguoChronology.INSTANCE.resolveDate(fieldValues, style);
        assertEquals(date, null);
        assertEquals(fieldValues.get(field), (Long) expected.longValue());
        assertEquals(fieldValues.size(), 1);
    } else {
        try {
            MinguoChronology.INSTANCE.resolveDate(fieldValues, style);
            fail("Should have failed");
        } catch (DateTimeException ex) {
            // expected
        }
    }
}
项目:openjdk9    文件:TCKMinguoChronology.java   
@Test(dataProvider = "resolve_yearOfEra")
public void test_resolve_yearOfEra(ResolverStyle style, Integer e, Integer yoe, Integer y, ChronoField field, Integer expected) {
    Map<TemporalField, Long> fieldValues = new HashMap<>();
    if (e != null) {
        fieldValues.put(ChronoField.ERA, (long) e);
    }
    if (yoe != null) {
        fieldValues.put(ChronoField.YEAR_OF_ERA, (long) yoe);
    }
    if (y != null) {
        fieldValues.put(ChronoField.YEAR, (long) y);
    }
    if (field != null) {
        MinguoDate date = MinguoChronology.INSTANCE.resolveDate(fieldValues, style);
        assertEquals(date, null);
        assertEquals(fieldValues.get(field), (Long) expected.longValue());
        assertEquals(fieldValues.size(), 1);
    } else {
        try {
            MinguoChronology.INSTANCE.resolveDate(fieldValues, style);
            fail("Should have failed");
        } catch (DateTimeException ex) {
            // expected
        }
    }
}
项目:openjdk9    文件:TCKMinguoChronology.java   
@Test(dataProvider = "resolve_ymd")
public void test_resolve_ymd_strict(int y, int m, int d, MinguoDate 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) {
        MinguoDate date = MinguoChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.STRICT);
        assertEquals(date, expected);
        assertEquals(fieldValues.size(), 0);
    } else {
        try {
            MinguoChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.STRICT);
            fail("Should have failed");
        } catch (DateTimeException ex) {
            // expected
        }
    }
}
项目:openjdk9    文件:TCKMinguoChronology.java   
@Test(dataProvider = "resolve_yd")
public void test_resolve_yd_smart(int y, int d, MinguoDate 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) {
        MinguoDate date = MinguoChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.SMART);
        assertEquals(date, expected);
        assertEquals(fieldValues.size(), 0);
    } else {
        try {
            MinguoChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.SMART);
            fail("Should have failed");
        } catch (DateTimeException ex) {
            // expected
        }
    }
}
项目:openjdk9    文件:TCKMinguoChronology.java   
@Test(dataProvider = "resolve_yd")
public void test_resolve_yd_strict(int y, int d, MinguoDate 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) {
        MinguoDate date = MinguoChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.STRICT);
        assertEquals(date, expected);
        assertEquals(fieldValues.size(), 0);
    } else {
        try {
            MinguoChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.STRICT);
            fail("Should have failed");
        } catch (DateTimeException ex) {
            // expected
        }
    }
}
项目:openjdk9    文件:TCKMinguoChronology.java   
@Test(dataProvider = "resolve_ymaa")
public void test_resolve_ymaa_smart(int y, int m, int w, int d, MinguoDate expected, boolean 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.ALIGNED_WEEK_OF_MONTH, (long) w);
    fieldValues.put(ChronoField.ALIGNED_DAY_OF_WEEK_IN_MONTH, (long) d);
    if (smart) {
        MinguoDate date = MinguoChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.SMART);
        assertEquals(date, expected);
        assertEquals(fieldValues.size(), 0);
    } else {
        try {
            MinguoChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.SMART);
            fail("Should have failed");
        } catch (DateTimeException ex) {
            // expected
        }
    }
}
项目:openjdk9    文件:TCKMinguoChronology.java   
@Test(dataProvider = "resolve_ymaa")
public void test_resolve_ymaa_strict(int y, int m, int w, int d, MinguoDate expected, boolean 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.ALIGNED_WEEK_OF_MONTH, (long) w);
    fieldValues.put(ChronoField.ALIGNED_DAY_OF_WEEK_IN_MONTH, (long) d);
    if (strict) {
        MinguoDate date = MinguoChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.STRICT);
        assertEquals(date, expected);
        assertEquals(fieldValues.size(), 0);
    } else {
        try {
            MinguoChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.STRICT);
            fail("Should have failed");
        } catch (DateTimeException ex) {
            // expected
        }
    }
}
项目:openjdk9    文件:TestReducedPrinter.java   
public void test_minguoChrono_fixedWidth() throws Exception {
    // ISO 2021 is Minguo 110
    DateTimeFormatter f = getFormatterBaseDate(YEAR, 2, 2, 2021);
    MinguoDate date = MinguoDate.of(109, 6, 30);
    assertEquals(f.format(date), "09");
    date = MinguoDate.of(110, 6, 30);
    assertEquals(f.format(date), "10");
    date = MinguoDate.of(199, 6, 30);
    assertEquals(f.format(date), "99");
    date = MinguoDate.of(200, 6, 30);
    assertEquals(f.format(date), "00");
    date = MinguoDate.of(209, 6, 30);
    assertEquals(f.format(date), "09");
    date = MinguoDate.of(210, 6, 30);
    assertEquals(f.format(date), "10");
}
项目:openjdk9    文件:TestReducedPrinter.java   
public void test_minguoChrono_extendedWidth() throws Exception {
    // ISO 2021 is Minguo 110
    DateTimeFormatter f = getFormatterBaseDate(YEAR, 2, 4, 2021);
    MinguoDate date = MinguoDate.of(109, 6, 30);
    assertEquals(f.format(date), "109");
    date = MinguoDate.of(110, 6, 30);
    assertEquals(f.format(date), "10");
    date = MinguoDate.of(199, 6, 30);
    assertEquals(f.format(date), "99");
    date = MinguoDate.of(200, 6, 30);
    assertEquals(f.format(date), "00");
    date = MinguoDate.of(209, 6, 30);
    assertEquals(f.format(date), "09");
    date = MinguoDate.of(210, 6, 30);
    assertEquals(f.format(date), "210");
}
项目:lookaside_java-1.8.0-openjdk    文件:TCKMinguoChronology.java   
@Test(dataProvider = "resolve_ymaa")
public void test_resolve_ymaa_strict(int y, int m, int w, int d, MinguoDate expected, boolean 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.ALIGNED_WEEK_OF_MONTH, (long) w);
    fieldValues.put(ChronoField.ALIGNED_DAY_OF_WEEK_IN_MONTH, (long) d);
    if (strict) {
        MinguoDate date = MinguoChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.STRICT);
        assertEquals(date, expected);
        assertEquals(fieldValues.size(), 0);
    } else {
        try {
            MinguoChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.STRICT);
            fail("Should have failed");
        } catch (DateTimeException ex) {
            // expected
        }
    }
}
项目:jdk8u_jdk    文件:TCKMinguoChronology.java   
@Test
public void test_dateNow(){
    assertEquals(MinguoChronology.INSTANCE.dateNow(), MinguoDate.now()) ;
    assertEquals(MinguoChronology.INSTANCE.dateNow(), MinguoDate.now(ZoneId.systemDefault())) ;
    assertEquals(MinguoChronology.INSTANCE.dateNow(), MinguoDate.now(Clock.systemDefaultZone())) ;
    assertEquals(MinguoChronology.INSTANCE.dateNow(), MinguoDate.now(Clock.systemDefaultZone().getZone())) ;

    assertEquals(MinguoChronology.INSTANCE.dateNow(), MinguoChronology.INSTANCE.dateNow(ZoneId.systemDefault())) ;
    assertEquals(MinguoChronology.INSTANCE.dateNow(), MinguoChronology.INSTANCE.dateNow(Clock.systemDefaultZone())) ;
    assertEquals(MinguoChronology.INSTANCE.dateNow(), MinguoChronology.INSTANCE.dateNow(Clock.systemDefaultZone().getZone())) ;

    ZoneId zoneId = ZoneId.of("Europe/Paris");
    assertEquals(MinguoChronology.INSTANCE.dateNow(zoneId), MinguoChronology.INSTANCE.dateNow(Clock.system(zoneId))) ;
    assertEquals(MinguoChronology.INSTANCE.dateNow(zoneId), MinguoChronology.INSTANCE.dateNow(Clock.system(zoneId).getZone())) ;
    assertEquals(MinguoChronology.INSTANCE.dateNow(zoneId), MinguoDate.now(Clock.system(zoneId))) ;
    assertEquals(MinguoChronology.INSTANCE.dateNow(zoneId), MinguoDate.now(Clock.system(zoneId).getZone())) ;

    assertEquals(MinguoChronology.INSTANCE.dateNow(ZoneId.of(ZoneOffset.UTC.getId())), MinguoChronology.INSTANCE.dateNow(Clock.systemUTC())) ;
}
项目:jdk8u_jdk    文件:TCKMinguoChronology.java   
@SuppressWarnings("unused")
@Test(dataProvider="samples")
public void test_MinguoDate(MinguoDate minguoDate, LocalDate iso) {
    MinguoDate hd = minguoDate;
    ChronoLocalDateTime<MinguoDate> hdt = hd.atTime(LocalTime.NOON);
    ZoneOffset zo = ZoneOffset.ofHours(1);
    ChronoZonedDateTime<MinguoDate> hzdt = hdt.atZone(zo);
    hdt = hdt.plus(1, ChronoUnit.YEARS);
    hdt = hdt.plus(1, ChronoUnit.MONTHS);
    hdt = hdt.plus(1, ChronoUnit.DAYS);
    hdt = hdt.plus(1, ChronoUnit.HOURS);
    hdt = hdt.plus(1, ChronoUnit.MINUTES);
    hdt = hdt.plus(1, ChronoUnit.SECONDS);
    hdt = hdt.plus(1, ChronoUnit.NANOS);
    ChronoLocalDateTime<MinguoDate> a2 = hzdt.toLocalDateTime();
    MinguoDate a3 = a2.toLocalDate();
    MinguoDate a5 = hzdt.toLocalDate();
    //System.out.printf(" d: %s, dt: %s; odt: %s; zodt: %s; a4: %s%n", date, hdt, hodt, hzdt, a5);
}
项目:lookaside_java-1.8.0-openjdk    文件:TCKMinguoChronology.java   
@Test(dataProvider = "resolve_ymd")
public void test_resolve_ymd_strict(int y, int m, int d, MinguoDate 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) {
        MinguoDate date = MinguoChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.STRICT);
        assertEquals(date, expected);
        assertEquals(fieldValues.size(), 0);
    } else {
        try {
            MinguoChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.STRICT);
            fail("Should have failed");
        } catch (DateTimeException ex) {
            // expected
        }
    }
}
项目:jdk8u_jdk    文件:TCKMinguoChronology.java   
@Test(dataProvider = "resolve_yearOfEra")
public void test_resolve_yearOfEra(ResolverStyle style, Integer e, Integer yoe, Integer y, ChronoField field, Integer expected) {
    Map<TemporalField, Long> fieldValues = new HashMap<>();
    if (e != null) {
        fieldValues.put(ChronoField.ERA, (long) e);
    }
    if (yoe != null) {
        fieldValues.put(ChronoField.YEAR_OF_ERA, (long) yoe);
    }
    if (y != null) {
        fieldValues.put(ChronoField.YEAR, (long) y);
    }
    if (field != null) {
        MinguoDate date = MinguoChronology.INSTANCE.resolveDate(fieldValues, style);
        assertEquals(date, null);
        assertEquals(fieldValues.get(field), (Long) expected.longValue());
        assertEquals(fieldValues.size(), 1);
    } else {
        try {
            MinguoChronology.INSTANCE.resolveDate(fieldValues, style);
            fail("Should have failed");
        } catch (DateTimeException ex) {
            // expected
        }
    }
}
项目:jdk8u_jdk    文件:TCKMinguoChronology.java   
@Test(dataProvider = "resolve_ymd")
public void test_resolve_ymd_strict(int y, int m, int d, MinguoDate 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) {
        MinguoDate date = MinguoChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.STRICT);
        assertEquals(date, expected);
        assertEquals(fieldValues.size(), 0);
    } else {
        try {
            MinguoChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.STRICT);
            fail("Should have failed");
        } catch (DateTimeException ex) {
            // expected
        }
    }
}
项目:jdk8u_jdk    文件:TCKMinguoChronology.java   
@Test(dataProvider = "resolve_yd")
public void test_resolve_yd_strict(int y, int d, MinguoDate 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) {
        MinguoDate date = MinguoChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.STRICT);
        assertEquals(date, expected);
        assertEquals(fieldValues.size(), 0);
    } else {
        try {
            MinguoChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.STRICT);
            fail("Should have failed");
        } catch (DateTimeException ex) {
            // expected
        }
    }
}