java.time.MonthDay.isBefore() 方法示例



說明

java.time.MonthDay.isBefore(MonthDay other) 方法檢查此月日是否位於指定月日之前。

宣告

以下是 java.time.MonthDay.isBefore(MonthDay other) 方法的宣告。

public boolean isBefore(MonthDay other)

public boolean isBefore(MonthDay other)

引數

other - 與之比較的另一個月日,不能為 null。

返回值

如果此月日早於指定月日,則返回 true。

示例

package com.tutorialspoint;

import java.time.MonthDay;

public class MonthDayDemo {
   public static void main(String[] args) {
 
      MonthDay date = MonthDay.parse("--12-30");
      MonthDay date1 = MonthDay.parse("--12-20");
      System.out.println(date1.isBefore(date));  
   }
}

即時演示

true
列印頁面
© . All rights reserved.