Java Date Time - LocalTime withSecond(int second) example








LocalTime withSecond(int second) returns a copy of this LocalTime with the second-of-minute value altered.

Syntax

withSecond has the following syntax.

public LocalTime withSecond(int second)

Example

The following example shows how to use withSecond.

import java.time.LocalTime;

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