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



說明

java.time.OffsetDateTime.isBefore(OffsetDateTime other) 方法檢查此日期是否在指定日期之前。

宣告

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

public boolean isBefore(OffsetDateTime other)

引數

other - 要比較的其他日期時間,不為 null。

返回值

如果此日期在指定日期之前,則返回 true。

示例

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

package com.tutorialspoint;

import java.time.OffsetDateTime;

public class OffsetDateTimeDemo {
   public static void main(String[] args) {
 
      OffsetDateTime date = OffsetDateTime.parse("2017-02-03T12:30:30+01:00");
      OffsetDateTime date1 = OffsetDateTime.parse("2017-03-03T12:30:30+01:00");
      System.out.println(date1.isBefore(date));  
   }
}

讓我們編譯並執行以上程式,將生成以下結果 -

false
廣告
© . All rights reserved.