Java Date Time - LocalTime with(TemporalAdjuster adjuster) example








LocalTime with(TemporalAdjuster adjuster) returns an adjusted copy of this time.

Syntax

with has the following syntax.

public LocalTime with(TemporalAdjuster adjuster)

Example

The following example shows how to use with.

import java.time.LocalTime;

public class Main {
  public static void main(String[] args) {
    LocalTime l = LocalTime.now();
    LocalTime s = l.with(LocalTime.NOON);
    System.out.println(s);
  }
}

The code above generates the following result.