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

项目:data-prep    文件:DateCalendarConverterTest.java   
@Test(expected = DateTimeException.class)
public void shouldNotParseNull() {

    // given
    List<DatePattern> patterns = Arrays.asList(new DatePattern("M/d/yyyy"), new DatePattern("dd-MMM-yyyy"));
    AbstractChronology chronology = DateCalendarConverter.CalendarUnit.ISO.getCalendarType();
    Locale locale = Locale.US;

    // then
    parseDateFromPatterns(null, patterns, chronology, locale);

}
项目:data-prep    文件:DateCalendarConverterTest.java   
@Test(expected = DateTimeException.class)
public void testEmptyListPatterns() {

    // given
    String value = "02-Dec-197";
    List<DatePattern> patterns = new ArrayList<>();
    AbstractChronology chronology = DateCalendarConverter.CalendarUnit.ISO.getCalendarType();
    Locale locale = Locale.US;

    // then
    parseDateFromPatterns(value, patterns, chronology, locale);

}
项目:data-prep    文件:DateCalendarConverterTest.java   
@Test(expected = IllegalArgumentException.class)
public void testWrongPatterns() {

    // given
    String value = "02-Dec-197";
    List<DatePattern> patterns = Arrays.asList(new DatePattern("a/bb/cccc"), new DatePattern("tt/zzz/fffff"));
    AbstractChronology chronology = DateCalendarConverter.CalendarUnit.ISO.getCalendarType();
    Locale locale = Locale.US;

    // then
    parseDateFromPatterns(value, patterns, chronology, locale);

}
项目:data-prep    文件:DateCalendarConverterTest.java   
@Test
public void testLitteralMonthsParseDateFromPatterns() {

    List<DatePattern> patterns = Arrays.asList(new DatePattern("M/d/yyyy"), new DatePattern("dd-MMM-yyyy"),
            new DatePattern("MMMM d, yyyy"), new DatePattern("d MMMM yyyy"));
    AbstractChronology chronology = DateCalendarConverter.CalendarUnit.ISO.getCalendarType();

    // given
    String valueWithMonthInCapital = "02-FEB-1978";

    Locale localeUS = Locale.US;

    // then
    assertEquals(patterns.get(1).getPattern(),
            parseDateFromPatterns(valueWithMonthInCapital, patterns, chronology, localeUS));

    // given
    String valueMonthUSShortLitteral = "02-Dec-1997";

    // then
    assertEquals(patterns.get(1).getPattern(),
            parseDateFromPatterns(valueMonthUSShortLitteral, patterns, chronology, localeUS));

    // given
    String valueMonthUSLongLitteral = "2 February 1981";

    // then
    assertEquals(patterns.get(3).getPattern(),
            parseDateFromPatterns(valueMonthUSLongLitteral, patterns, chronology, localeUS));

    // given
    String valueMonthUSLongLitteral2 = "December 3, 2004";

    // then
    assertEquals(patterns.get(2).getPattern(),
            parseDateFromPatterns(valueMonthUSLongLitteral2, patterns, chronology, localeUS));

    // given
    Locale localeFr = Locale.FRANCE;
    String valueMonthFrLongLitteral = "4 Février 2030";

    // then
    assertEquals(patterns.get(3).getPattern(),
            parseDateFromPatterns(valueMonthFrLongLitteral, patterns, chronology, localeFr));

}