本文整理匯總了Java中java.time.MonthDay.parse方法的典型用法代碼示例。如果您正苦於以下問題:Java MonthDay.parse方法的具體用法?Java MonthDay.parse怎麽用?Java MonthDay.parse使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.time.MonthDay
的用法示例。
在下文中一共展示了MonthDay.parse方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: factory_parse_fail
import java.time.MonthDay; //導入方法依賴的package包/類
@Test(dataProvider="badParseData", expectedExceptions=DateTimeParseException.class)
public void factory_parse_fail(String text, int pos) {
try {
MonthDay.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;
}
}
示例2: factory_parse_success
import java.time.MonthDay; //導入方法依賴的package包/類
@Test(dataProvider="goodParseData")
public void factory_parse_success(String text, MonthDay expected) {
MonthDay monthDay = MonthDay.parse(text);
assertEquals(monthDay, expected);
}
示例3: factory_parse_illegalValue_Day
import java.time.MonthDay; //導入方法依賴的package包/類
@Test(expectedExceptions=DateTimeParseException.class)
public void factory_parse_illegalValue_Day() {
MonthDay.parse("--06-32");
}
示例4: factory_parse_invalidValue_Day
import java.time.MonthDay; //導入方法依賴的package包/類
@Test(expectedExceptions=DateTimeParseException.class)
public void factory_parse_invalidValue_Day() {
MonthDay.parse("--06-31");
}
示例5: factory_parse_illegalValue_Month
import java.time.MonthDay; //導入方法依賴的package包/類
@Test(expectedExceptions=DateTimeParseException.class)
public void factory_parse_illegalValue_Month() {
MonthDay.parse("--13-25");
}
示例6: factory_parse_nullText
import java.time.MonthDay; //導入方法依賴的package包/類
@Test(expectedExceptions=NullPointerException.class)
public void factory_parse_nullText() {
MonthDay.parse(null);
}
示例7: factory_parse_formatter
import java.time.MonthDay; //導入方法依賴的package包/類
@Test
public void factory_parse_formatter() {
DateTimeFormatter f = DateTimeFormatter.ofPattern("M d");
MonthDay test = MonthDay.parse("12 3", f);
assertEquals(test, MonthDay.of(12, 3));
}
示例8: factory_parse_formatter_nullText
import java.time.MonthDay; //導入方法依賴的package包/類
@Test(expectedExceptions=NullPointerException.class)
public void factory_parse_formatter_nullText() {
DateTimeFormatter f = DateTimeFormatter.ofPattern("M d");
MonthDay.parse((String) null, f);
}
示例9: factory_parse_formatter_nullFormatter
import java.time.MonthDay; //導入方法依賴的package包/類
@Test(expectedExceptions=NullPointerException.class)
public void factory_parse_formatter_nullFormatter() {
MonthDay.parse("ANY", null);
}