MonthDay 类的 getDayOfMonth() 方法
可以使用 Java 中 MonthDay 类的 getDayOfMonth() 方法获取特定 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());
广告
数据结构
网络
RDBMS
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP