Java Date Time - OffsetTime withSecond(int second) example








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

Syntax

withSecond has the following syntax.

public OffsetTime withSecond(int second)

Example

The following example shows how to use withSecond.

import java.time.OffsetTime;
// w w  w . j a va 2s.  c  o  m
public class Main {
  public static void main(String[] args) {
    OffsetTime m = OffsetTime.now();
    OffsetTime n = m.withSecond(34);
    System.out.println(n);

  }
}

The code above generates the following result.