Java中的Period of Months()方法
可以使用ofMonths()Java的Period类中的方法以给定的月数获得Period。此方法需要一个参数,即月数,并返回具有给定月数的Period对象。
演示此的程序如下所示-
示例
import java.time.Period;
public class Demo {
public static void main(String[] args) {
int months = 11;
Period p = Period.ofMonths(months);
System.out.println("The Period is: " + p);
}
}输出结果
The Period is: P11M
现在让我们了解上面的程序。
使用该ofMonths()方法以给定的月数获得期间,然后将其打印出来。演示这的代码片段如下-
int months = 11;
Period p = Period.ofMonths(months);
System.out.println("The Period is: " + p);热门推荐
10 小红书平安祝福语简短
11 生日祝福语大全女孩简短
12 收生日红包祝福语 简短
13 领证幽默祝福语简短
14 法考面试祝福语简短
15 老哥出门祝福语简短语
16 送灯祝福语简短独特
17 幼儿狗年祝福语大全简短
18 好听的元旦简短祝福语