Java Date Time - ZonedDateTime withSecond(int second) example








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

Syntax

withSecond has the following syntax.

public ZonedDateTime withSecond(int second)

Example

The following example shows how to use withSecond.

import java.time.ZonedDateTime;

public class Main {
  public static void main(String[] args) {
    ZonedDateTime dateTime = ZonedDateTime.now();
    ZonedDateTime n = dateTime.withSecond(1234);
    System.out.println(n);
  } 
}