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



說明

java.time.Month.minus(long months) 方法返回比此月份早的指定月數的月份。

宣告

以下是對 **java.time.Month.minus(long months)** 方法的宣告。

public Month minus(long months)

引數

months - 要減去的月份,可以為正數或負數。

返回值

生成月份,不為 null。

示例

以下示例演示了 java.time.Month.minus(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.minus(1));  
   }
}

讓我們編譯並執行上述程式,生成如下結果:

MAY
APRIL
廣告
© . All rights reserved.