From f6cddd2cd766bd2d78ba7314928e2a12e63bf2ba Mon Sep 17 00:00:00 2001 From: Deanna Garcia Date: Tue, 29 Oct 2024 12:22:54 -0700 Subject: [PATCH] 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 --- .../com/google/protobuf/util/Durations.java | 24 +----------- .../com/google/protobuf/util/Timestamps.java | 38 ++----------------- 2 files changed, 5 insertions(+), 57 deletions(-) diff --git a/java/util/src/main/java/com/google/protobuf/util/Durations.java b/java/util/src/main/java/com/google/protobuf/util/Durations.java index 2d5be3471827..059cc4fb3699 100644 --- a/java/util/src/main/java/com/google/protobuf/util/Durations.java +++ b/java/util/src/main/java/com/google/protobuf/util/Durations.java @@ -427,17 +427,7 @@ public static long toNanos(Duration duration) { // Math operations - /** - * Add two durations. - * - * - * @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}. - * - */ - @Deprecated // MOE:strip_line + /** Add two durations. */ public static Duration add(Duration d1, Duration d2) { checkValid(d1); checkValid(d2); @@ -445,17 +435,7 @@ public static Duration add(Duration d1, Duration d2) { checkedAdd(d1.getSeconds(), d2.getSeconds()), checkedAdd(d1.getNanos(), d2.getNanos())); } - /** - * Subtract a duration from another. - * - * - * @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}. - * - */ - @Deprecated // MOE:strip_line + /** Subtract a duration from another. */ public static Duration subtract(Duration d1, Duration d2) { checkValid(d1); checkValid(d2); diff --git a/java/util/src/main/java/com/google/protobuf/util/Timestamps.java b/java/util/src/main/java/com/google/protobuf/util/Timestamps.java index 706fc319e4b4..7a5558c8115f 100644 --- a/java/util/src/main/java/com/google/protobuf/util/Timestamps.java +++ b/java/util/src/main/java/com/google/protobuf/util/Timestamps.java @@ -437,17 +437,7 @@ public static long toNanos(Timestamp timestamp) { checkedMultiply(timestamp.getSeconds(), NANOS_PER_SECOND), timestamp.getNanos()); } - /** - * Calculate the difference between two timestamps. - * - * - * @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}. - * - */ - @Deprecated // MOE:strip_line + /** Calculate the difference between two timestamps. */ public static Duration between(Timestamp from, Timestamp to) { checkValid(from); checkValid(to); @@ -456,18 +446,7 @@ public static Duration between(Timestamp from, Timestamp to) { checkedSubtract(to.getNanos(), from.getNanos())); } - /** - * Add a duration to a timestamp. - * - * - * @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}. - * - */ - @Deprecated // MOE:strip_line + /** Add a duration to a timestamp. */ public static Timestamp add(Timestamp start, Duration length) { checkValid(start); Durations.checkValid(length); @@ -476,18 +455,7 @@ public static Timestamp add(Timestamp start, Duration length) { checkedAdd(start.getNanos(), length.getNanos())); } - /** - * Subtract a duration from a timestamp. - * - * - * @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}. - * - */ - @Deprecated // MOE:strip_line + /** Subtract a duration from a timestamp. */ public static Timestamp subtract(Timestamp start, Duration length) { checkValid(start); Durations.checkValid(length);