Skip to content

Commit

Permalink
Merge pull request #19077 from deannagarcia/29.x
Browse files Browse the repository at this point in the history
Remove deprecation warnings for Timestamp and Duration add/subtract/between
  • Loading branch information
deannagarcia authored Oct 31, 2024
2 parents 53cde64 + f606c13 commit bc42bd2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 57 deletions.
24 changes: 2 additions & 22 deletions java/util/src/main/java/com/google/protobuf/util/Durations.java
Original file line number Diff line number Diff line change
Expand Up @@ -422,35 +422,15 @@ public static long toNanos(Duration duration) {

// Math operations

/**
* 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
/** Add two durations. */
public static Duration add(Duration d1, Duration d2) {
checkValid(d1);
checkValid(d2);
return normalizedDuration(
checkedAdd(d1.getSeconds(), d2.getSeconds()), checkedAdd(d1.getNanos(), d2.getNanos()));
}

/**
* 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
/** Subtract a duration from another. */
public static Duration subtract(Duration d1, Duration d2) {
checkValid(d1);
checkValid(d2);
Expand Down
38 changes: 3 additions & 35 deletions java/util/src/main/java/com/google/protobuf/util/Timestamps.java
Original file line number Diff line number Diff line change
Expand Up @@ -437,17 +437,7 @@ public static long toNanos(Timestamp timestamp) {
checkedMultiply(timestamp.getSeconds(), NANOS_PER_SECOND), timestamp.getNanos());
}

/**
* 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
/** Calculate the difference between two timestamps. */
public static Duration between(Timestamp from, Timestamp to) {
checkValid(from);
checkValid(to);
Expand All @@ -456,18 +446,7 @@ public static Duration between(Timestamp from, Timestamp to) {
checkedSubtract(to.getNanos(), from.getNanos()));
}

/**
* 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
/** Add a duration to a timestamp. */
public static Timestamp add(Timestamp start, Duration length) {
checkValid(start);
Durations.checkValid(length);
Expand All @@ -476,18 +455,7 @@ public static Timestamp add(Timestamp start, Duration length) {
checkedAdd(start.getNanos(), length.getNanos()));
}

/**
* 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
/** Subtract a duration from a timestamp. */
public static Timestamp subtract(Timestamp start, Duration length) {
checkValid(start);
Durations.checkValid(length);
Expand Down

0 comments on commit bc42bd2

Please sign in to comment.