本文整理汇总了Java中java.time.chrono.AbstractChronology类的典型用法代码示例。如果您正苦于以下问题:Java AbstractChronology类的具体用法?Java AbstractChronology怎么用?Java AbstractChronology使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
AbstractChronology类属于java.time.chrono包,在下文中一共展示了AbstractChronology类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: shouldNotParseNull
import java.time.chrono.AbstractChronology; //导入依赖的package包/类
@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);
}
示例2: testEmptyListPatterns
import java.time.chrono.AbstractChronology; //导入依赖的package包/类
@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);
}
示例3: testWrongPatterns
import java.time.chrono.AbstractChronology; //导入依赖的package包/类
@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);
}
示例4: testLitteralMonthsParseDateFromPatterns
import java.time.chrono.AbstractChronology; //导入依赖的package包/类
@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));
}