java.time.MonthDay.parse(CharSequence text)
方法从文本字符串(例如 - 10-15
)获取MonthDay的实例。
声明
以下是java.time.MonthDay.parse(CharSequence text)
方法的声明。
public static MonthDay parse(CharSequence text)
参数
text
- 要解析的文本,例如"--10-15"
,而不是null
。
返回值
当地的月日,不是null
。
异常
DateTimeParseException
- 如果无法解析文本。
示例
以下示例显示了java.time.MonthDay.parse(CharSequence text)
方法的用法。
package com.yiibai;
import java.time.MonthDay;
public class MonthDayDemo {
public static void main(String[] args) {
MonthDay time = MonthDay.parse("--10-15");
System.out.println(time);
}
}
编译并运行上面的程序,这将产生以下结果 -
--10-15