java.time.YearMonth.equals(YearMonth otherYearMonth)方法

java.time.YearMonth.equals(YearMonth otherYearMonth)方法检查此YearMonth是否等于指定的YearMonth

声明

以下是java.time.YearMonth.equals(YearMonth otherYearMonth)方法的声明。

public int equals(YearMonth otherYearMonth)

参数

  • otherYearMonth - 另一个YearMonth,如果是null则返回false

返回值

如果另一个YearMonth等于此年月,则返回true

示例

以下示例显示了java.time.YearMonth.equals(YearMonth otherYearMonth)方法的用法。

package com.zaixian;

import java.time.YearMonth;

public class YearMonthDemo {
   public static void main(String[] args) {

      YearMonth date = YearMonth.of(2005,11);
      YearMonth date1 = YearMonth.of(2006,12);
      System.out.println(date.equals(date1));
   }
}

编译并运行上面的程序,这将产生以下结果 -

false

上一篇: java.time.YearMonth类 下一篇: java.time.ZonedDateTime类