Java Date Time Java Java API
java.time.ZonedDateTime
public ZonedDateTime withSecond(int second)
package com.logicbig.example.zoneddatetime;import java.time.ZoneId;import java.time.ZonedDateTime;public class WithSecondExample { public static void main(String... args) { ZonedDateTime d = ZonedDateTime.of(2017, 2, 12, 20, 33, 23, 0, ZoneId.of("America/Chicago")); System.out.println(d); ZonedDateTime d2 = d.withSecond(10); System.out.println(d2); ZonedDateTime d3 = d.withSecond(0); System.out.println(d3); }}
2017-02-12T20:33:23-06:00[America/Chicago]2017-02-12T20:33:10-06:00[America/Chicago]2017-02-12T20:33-06:00[America/Chicago]