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.