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



說明

java.time.LocalTime.isBefore(LocalTime other) 方法檢查當前時間是否早於指定時間。

宣告

以下是 java.time.LocalTime.isBefore(LocalTime other) 方法的宣告:

public boolean isBefore(LocalTime other)

引數

other - 用於比較的另一個 time,非空。

返回值

如果當前時間早於指定的時間,則返回 true。

示例

以下示例展示了 java.time.LocalTime.isBefore(LocalTime other) 方法的使用:

package com.tutorialspoint;

import java.time.LocalTime;

public class LocalTimeDemo {
   public static void main(String[] args) {
 
      LocalTime time = LocalTime.parse("12:30:30");
      LocalTime time1 = LocalTime.parse("12:35:30");
      System.out.println(time1.isBefore(time));  
   }
}

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

false
廣告
© . All rights reserved.