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



說明

java.time.LocalTime.with(TemporalAdjuster adjuster) 方法返回此時間的已調整副本。

宣告

以下為 java.time.LocalTime.with(TemporalAdjuster adjuster) 方法的宣告。

public LocalTime with(TemporalAdjuster adjuster)

引數

adjuster - 要使用的調整器,非空。

返回值

基於已經進行調整的此時間副本,非空。

異常

  • DateTimeException - 如果無法進行調整。

  • ArithmeticException - 如果出現數字溢位。

示例

以下示例顯示了 java.time.LocalTime.with(TemporalAdjuster adjuster) 方法的使用。

package com.tutorialspoint;

import java.time.LocalTime;

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

      LocalTime date = LocalTime.parse("10:15:30");
      LocalTime result = date.with(LocalTime.NOON);
      System.out.println(result);  
   }
}

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

12:00
廣告
© . All rights reserved.