Remove deprecation warnings for Timestamp and Duration add/subtract/between that we do not yet have alternatives to.

Fixes https://github.com/protocolbuffers/protobuf/issues/18925

PiperOrigin-RevId: 691117251
pull/19018/head
Deanna Garcia 5 months ago committed by Copybara-Service
parent 6cb7140294
commit f6cddd2cd7
  1. 24
      java/util/src/main/java/com/google/protobuf/util/Durations.java
  2. 38
      java/util/src/main/java/com/google/protobuf/util/Timestamps.java

@ -427,17 +427,7 @@ public final class Durations {
// Math operations // Math operations
/** /** Add two durations. */
* Add two durations.
*
* <!-- MOE:begin_intracomment_strip -->
* @deprecated Do not use this method for new code. Instead, convert to {@link java.time.Duration}
* using {@link com.google.protobuf.util.JavaTimeConversions#toJavaDuration}, do the
* arithmetic there, and convert back using {@link
* com.google.protobuf.util.JavaTimeConversions#toProtoDuration}.
* <!-- MOE:end_intracomment_strip -->
*/
@Deprecated // MOE:strip_line
public static Duration add(Duration d1, Duration d2) { public static Duration add(Duration d1, Duration d2) {
checkValid(d1); checkValid(d1);
checkValid(d2); checkValid(d2);
@ -445,17 +435,7 @@ public final class Durations {
checkedAdd(d1.getSeconds(), d2.getSeconds()), checkedAdd(d1.getNanos(), d2.getNanos())); checkedAdd(d1.getSeconds(), d2.getSeconds()), checkedAdd(d1.getNanos(), d2.getNanos()));
} }
/** /** Subtract a duration from another. */
* Subtract a duration from another.
*
* <!-- MOE:begin_intracomment_strip -->
* @deprecated Do not use this method for new code. Instead, convert to {@link java.time.Duration}
* using {@link com.google.protobuf.util.JavaTimeConversions#toJavaDuration}, do the
* arithmetic there, and convert back using {@link
* com.google.protobuf.util.JavaTimeConversions#toProtoDuration}.
* <!-- MOE:end_intracomment_strip -->
*/
@Deprecated // MOE:strip_line
public static Duration subtract(Duration d1, Duration d2) { public static Duration subtract(Duration d1, Duration d2) {
checkValid(d1); checkValid(d1);
checkValid(d2); checkValid(d2);

@ -437,17 +437,7 @@ public final class Timestamps {
checkedMultiply(timestamp.getSeconds(), NANOS_PER_SECOND), timestamp.getNanos()); checkedMultiply(timestamp.getSeconds(), NANOS_PER_SECOND), timestamp.getNanos());
} }
/** /** Calculate the difference between two timestamps. */
* Calculate the difference between two timestamps.
*
* <!-- MOE:begin_intracomment_strip -->
* @deprecated Do not use this method for new code. Instead, convert to {@link java.time.Instant}
* using {@link com.google.protobuf.util.JavaTimeConversions#toJavaInstant}, do the arithmetic
* there, and convert back using {@link
* com.google.protobuf.util.JavaTimeConversions#toProtoDuration}.
* <!-- MOE:end_intracomment_strip -->
*/
@Deprecated // MOE:strip_line
public static Duration between(Timestamp from, Timestamp to) { public static Duration between(Timestamp from, Timestamp to) {
checkValid(from); checkValid(from);
checkValid(to); checkValid(to);
@ -456,18 +446,7 @@ public final class Timestamps {
checkedSubtract(to.getNanos(), from.getNanos())); checkedSubtract(to.getNanos(), from.getNanos()));
} }
/** /** Add a duration to a timestamp. */
* Add a duration to a timestamp.
*
* <!-- MOE:begin_intracomment_strip -->
* @deprecated Do not use this method for new code. Instead, convert to {@link java.time.Instant}
* and {@link java.time.Duration} using {@link
* com.google.protobuf.util.JavaTimeConversions#toJavaInstant} and {@link
* com.google.protobuf.util.JavaTimeConversions#toJavaDuration}, do the arithmetic there, and
* convert back using {@link com.google.protobuf.util.JavaTimeConversions#toProtoTimestamp}.
* <!-- MOE:end_intracomment_strip -->
*/
@Deprecated // MOE:strip_line
public static Timestamp add(Timestamp start, Duration length) { public static Timestamp add(Timestamp start, Duration length) {
checkValid(start); checkValid(start);
Durations.checkValid(length); Durations.checkValid(length);
@ -476,18 +455,7 @@ public final class Timestamps {
checkedAdd(start.getNanos(), length.getNanos())); checkedAdd(start.getNanos(), length.getNanos()));
} }
/** /** Subtract a duration from a timestamp. */
* Subtract a duration from a timestamp.
*
* <!-- MOE:begin_intracomment_strip -->
* @deprecated Do not use this method for new code. Instead, convert to {@link java.time.Instant}
* and {@link java.time.Duration} using {@link
* com.google.protobuf.util.JavaTimeConversions#toJavaInstant} and {@link
* com.google.protobuf.util.JavaTimeConversions#toJavaDuration}, do the arithmetic there, and
* convert back using {@link com.google.protobuf.util.JavaTimeConversions#toProtoTimestamp}.
* <!-- MOE:end_intracomment_strip -->
*/
@Deprecated // MOE:strip_line
public static Timestamp subtract(Timestamp start, Duration length) { public static Timestamp subtract(Timestamp start, Duration length) {
checkValid(start); checkValid(start);
Durations.checkValid(length); Durations.checkValid(length);

Loading…
Cancel
Save