java.time.MonthDay.isBefore(MonthDay other)方法

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

聲明

以下是java.time.MonthDay.isBefore(MonthDay other)方法的聲明。

public boolean isBefore(MonthDay other)

參數

  • other - 比較的其他月份日,不能為null

返回值

如果此月-日在指定的月-日之前,則為true

以下示例顯示了java.time.MonthDay.isBefore(MonthDay other)方法的用法。

package com.zaixian;

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

上一篇: java.time.MonthDay類 下一篇: java.time.OffsetDateTime類