Java Date Time Java Java API
java.time.OffsetDateTime
public OffsetDateTime minusMinutes(long minutes)
Returns a copy of this OffsetDateTime with the specified number of minutes subtracted, adjusting other fields if necessary.
package com.logicbig.example.offsetdatetime;import java.time.LocalDateTime;import java.time.OffsetDateTime;import java.time.ZoneOffset;public class MinusMinutesExample { public static void main (String... args) { OffsetDateTime d = OffsetDateTime.of(LocalDateTime.of(2016, 10, 3, 14, 30), ZoneOffset.of("-5")); System.out.println(d); OffsetDateTime offsetDateTime = d.minusMinutes(15); System.out.println(offsetDateTime); OffsetDateTime offsetDateTime2 = d.minusMinutes(4000); System.out.println(offsetDateTime2); }}
2016-10-03T14:30-05:002016-10-03T14:15-05:002016-09-30T19:50-05:00
package com.logicbig.example.offsetdatetime;import java.time.LocalDateTime;import java.time.OffsetDateTime;import java.time.ZoneOffset;public class MinusMinutesExample2 { public static void main (String... args) { OffsetDateTime d = OffsetDateTime.of(LocalDateTime.of(2016, 10, 3, 14, 30), ZoneOffset.of("-5")); System.out.println(d); OffsetDateTime offsetDateTime = d.minusMinutes(-15); System.out.println(offsetDateTime); OffsetDateTime offsetDateTime2 = d.minusMinutes(-4000); System.out.println(offsetDateTime2); }}
2016-10-03T14:30-05:002016-10-03T14:45-05:002016-10-06T09:10-05:00