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());热门推荐
6 保研的祝福语简短
10 年轻20岁祝福语简短
11 朋友结婚祝福语信息简短
12 女孩婚礼贺卡祝福语简短
13 30段点歌简短祝福语
14 虎年春节祝福语图文简短
15 写给后妈祝福语大全简短
16 简短回复生日祝福语
17 校长送毕业祝福语简短
18 毕业立体贺卡祝福语简短