java.time.LocalDateTime.isEqual() 方法示例



說明

java.time.LocalDateTime.isEqual(ChronoLocalDateTime<?> other) 方法檢查此日期時間是否等於指定的日期時間。

宣告

以下是 java.time.LocalDateTime.isEqual(ChronoLocalDateTime<?> other) 方法的宣告。

public boolean isEqual(ChronoLocalDateTime<?> other)

引數

other - 要進行比較的另一個日期,非空。

返回值

如果此日期等於指定的日期,則返回 true。

示例

以下示例演示了 java.time.LocalDateTime.isEqual(ChronoLocalDateTime<?> other) 方法的使用。

package com.tutorialspoint;

import java.time.LocalDateTime;

public class LocalDateTimeDemo {
   public static void main(String[] args) {
 
      LocalDateTime date = LocalDateTime.parse("2017-02-03T12:30:30");
      LocalDateTime date1 = LocalDateTime.parse("2017-03-03T12:30:30");
      System.out.println(date1.isEqual(date));  
   }
}

讓我們編譯並執行上面的程式,它將產生以下結果 -

false
廣告
© . All rights reserved.