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.