Java中的MonthDay getMonth()方法
可以使用getMonth()Java中MonthDay类中的方法来获取特定MonthDay的月份名称。此方法不需要任何参数,它返回年份中的月份名称。
演示此程序如下
示例
import java.time.*;
public class Demo {
public static void main(String[] args) {
MonthDay md = MonthDay.parse("--02-22");
System.out.println("The MonthDay is: " + md);
System.out.println("The month is: " + md.getMonth());
}
}输出结果
The MonthDay is: --02-22 The month is: FEBRUARY
现在让我们了解上面的程序。
首先显示MonthDay。然后使用该getMonth()方法显示MonthDay的月份名称。演示此代码段如下所示:
MonthDay md = MonthDay.parse("--02-22");
System.out.println("The MonthDay is: " + md);
System.out.println("The month is: " + md.getMonth());热门推荐
10 财运虎年祝福语简短语
11 单亲爸爸春节祝福语简短
12 狗狗上厕所训练
13 植物种植祝福语简短
14 翻译考试祝福语朋友简短
15 个人周年庆简短祝福语
16 狗狗怎么训练
17 分别祝福语简短搞笑英文
18 生日广州男生祝福语简短