java.time.Month.plus() 方法示例



描述

java.time.Month.plus(long months) 方法指定的月份以月数为单位在前一个月份。

声明

这是 java.time.Month.plus(long months) 方法的声明。

public Month plus(long days)

参数

months − 要减去的月份,可以为正数或负数。

返回值

产生的月份,不能为空。

示例

以下示例展示了如何使用 java.time.Month.plus(long months) 方法。

package com.tutorialspoint;

import java.time.Month;

public class MonthDemo {
   public static void main(String[] args) {
 
      Month month = Month.of(5);
      System.out.println(month);  
      System.out.println(month.plus(1));  
   }
}

编译并运行上面的程序,将生成以下结果:-

MAY
JUNE
广告
© . All rights reserved.