本文整理汇总了Java中java.time.YearMonth.parse方法的典型用法代码示例。如果您正苦于以下问题:Java YearMonth.parse方法的具体用法?Java YearMonth.parse怎么用?Java YearMonth.parse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.time.YearMonth
的用法示例。
在下文中一共展示了YearMonth.parse方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isGeldigeKalendarDatum
import java.time.YearMonth; //导入方法依赖的package包/类
private boolean isGeldigeKalendarDatum() {
try {
if (isJaarOnbekend || isMaandOnbekend) {
return true;
} else if (isDagOnbekend) {
YearMonth.parse(jaar + maand, FORMATTER_JAAR_MND);
} else {
LocalDate.parse(jaar + maand + dag, DateTimeFormatter.BASIC_ISO_DATE);
}
} catch (final DateTimeException e) {
LOG.trace("Fout bij het parsen van datum " + this, e);
return false;
}
return true;
}
示例2: factory_parse_fail
import java.time.YearMonth; //导入方法依赖的package包/类
@Test(dataProvider="badParseData", expectedExceptions=DateTimeParseException.class)
public void factory_parse_fail(String text, int pos) {
try {
YearMonth.parse(text);
fail(String.format("Parse should have failed for %s at position %d", text, pos));
} catch (DateTimeParseException ex) {
assertEquals(ex.getParsedString(), text);
assertEquals(ex.getErrorIndex(), pos);
throw ex;
}
}
示例3: factory_parse_success
import java.time.YearMonth; //导入方法依赖的package包/类
@Test(dataProvider="goodParseData")
public void factory_parse_success(String text, YearMonth expected) {
YearMonth yearMonth = YearMonth.parse(text);
assertEquals(yearMonth, expected);
}
示例4: factory_parse_illegalValue_Month
import java.time.YearMonth; //导入方法依赖的package包/类
@Test(expectedExceptions=DateTimeParseException.class)
public void factory_parse_illegalValue_Month() {
YearMonth.parse("2008-13");
}
示例5: factory_parse_nullText
import java.time.YearMonth; //导入方法依赖的package包/类
@Test(expectedExceptions=NullPointerException.class)
public void factory_parse_nullText() {
YearMonth.parse(null);
}
示例6: factory_parse_formatter
import java.time.YearMonth; //导入方法依赖的package包/类
@Test
public void factory_parse_formatter() {
DateTimeFormatter f = DateTimeFormatter.ofPattern("y M");
YearMonth test = YearMonth.parse("2010 12", f);
assertEquals(test, YearMonth.of(2010, 12));
}
示例7: factory_parse_formatter_nullText
import java.time.YearMonth; //导入方法依赖的package包/类
@Test(expectedExceptions=NullPointerException.class)
public void factory_parse_formatter_nullText() {
DateTimeFormatter f = DateTimeFormatter.ofPattern("y M");
YearMonth.parse((String) null, f);
}
示例8: factory_parse_formatter_nullFormatter
import java.time.YearMonth; //导入方法依赖的package包/类
@Test(expectedExceptions=NullPointerException.class)
public void factory_parse_formatter_nullFormatter() {
YearMonth.parse("ANY", null);
}