Java中的MonthDay getDayOfMonth()方法
可以使用getDayOfMonth()Java中MonthDay类中的方法来获取特定MonthDay的月份。此方法不需要任何参数,它返回一个月中的某天,该范围可以在1到31之间。
演示此程序如下
示例
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 day of the month is: " + md.getDayOfMonth());
}
}输出结果
The MonthDay is: --02-22 The day of the month is: 22
现在让我们了解上面的程序。
首先显示MonthDay。然后使用该getDayOfMonth()方法显示MonthDay的月份。演示此代码段如下所示:
MonthDay md = MonthDay.parse("--02-22");
System.out.println("The MonthDay is: " + md);
System.out.println("The day of the month is: " + md.getDayOfMonth());热门推荐
10 祝女儿简短祝福语大全
11 大学新年祝福语简短创意
12 元旦适合的祝福语简短
13 朋友出远门祝福语简短
14 初六简短的祝福语
15 祝男孩生日祝福语简短
16 同事调离的祝福语简短
17 拜年红包的祝福语简短
18 妈妈生日祝福语简短励志