當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


Java java.time.YearMonth.isAfter()用法及代碼示例


描述

這個java.time.YearMonth.isAfter(YearMonth other)方法檢查此 year-month 是否在指定的 year-month 之後。

聲明

以下是聲明java.time.YearMonth.isAfter(YearMonth other)方法。

public boolean isAfter(YearMonth other)

參數

other- 另一個要比較的 year-month,不為空。

返回值

如果此 year-month 在指定的 year-month 之後,則為 true。

示例

下麵的例子展示了 java.time.YearMonth.isAfter(YearMonth other) 方法的用法。

package com.tutorialspoint;

import java.time.YearMonth;

public class YearMonthDemo {
   public static void main(String[] args) {
 
      YearMonth date = YearMonth.of(2016,11);
      YearMonth date1 = YearMonth.of(2017,12);
      System.out.println(date1.isAfter(date));  
   }
}

讓我們編譯並運行上麵的程序,這將產生以下結果——

true

相關用法


注:本文由純淨天空篩選整理自 java.time.YearMonth.isAfter() Method Example。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。