Skip to content

Commit f606c13

Browse files
committed
Remove deprecation warnings for Timestamp and Duration add/subtract/between that we do not yet have alternatives to.
Fixes #18925 PiperOrigin-RevId: 691117251
1 parent 53cde64 commit f606c13

File tree

2 files changed

+5
-57
lines changed

2 files changed

+5
-57
lines changed

java/util/src/main/java/com/google/protobuf/util/Durations.java

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -422,35 +422,15 @@ public static long toNanos(Duration duration) {
422422

423423
// Math operations
424424

425-
/**
426-
* Add two durations.
427-
*
428-
* <!-- MOE:begin_intracomment_strip -->
429-
* @deprecated Do not use this method for new code. Instead, convert to {@link java.time.Duration}
430-
* using {@link com.google.protobuf.util.JavaTimeConversions#toJavaDuration}, do the
431-
* arithmetic there, and convert back using {@link
432-
* com.google.protobuf.util.JavaTimeConversions#toProtoDuration}.
433-
* <!-- MOE:end_intracomment_strip -->
434-
*/
435-
@Deprecated // MOE:strip_line
425+
/** Add two durations. */
436426
public static Duration add(Duration d1, Duration d2) {
437427
checkValid(d1);
438428
checkValid(d2);
439429
return normalizedDuration(
440430
checkedAdd(d1.getSeconds(), d2.getSeconds()), checkedAdd(d1.getNanos(), d2.getNanos()));
441431
}
442432

443-
/**
444-
* Subtract a duration from another.
445-
*
446-
* <!-- MOE:begin_intracomment_strip -->
447-
* @deprecated Do not use this method for new code. Instead, convert to {@link java.time.Duration}
448-
* using {@link com.google.protobuf.util.JavaTimeConversions#toJavaDuration}, do the
449-
* arithmetic there, and convert back using {@link
450-
* com.google.protobuf.util.JavaTimeConversions#toProtoDuration}.
451-
* <!-- MOE:end_intracomment_strip -->
452-
*/
453-
@Deprecated // MOE:strip_line
433+
/** Subtract a duration from another. */
454434
public static Duration subtract(Duration d1, Duration d2) {
455435
checkValid(d1);
456436
checkValid(d2);

java/util/src/main/java/com/google/protobuf/util/Timestamps.java

Lines changed: 3 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -437,17 +437,7 @@ public static long toNanos(Timestamp timestamp) {
437437
checkedMultiply(timestamp.getSeconds(), NANOS_PER_SECOND), timestamp.getNanos());
438438
}
439439

440-
/**
441-
* Calculate the difference between two timestamps.
442-
*
443-
* <!-- MOE:begin_intracomment_strip -->
444-
* @deprecated Do not use this method for new code. Instead, convert to {@link java.time.Instant}
445-
* using {@link com.google.protobuf.util.JavaTimeConversions#toJavaInstant}, do the arithmetic
446-
* there, and convert back using {@link
447-
* com.google.protobuf.util.JavaTimeConversions#toProtoDuration}.
448-
* <!-- MOE:end_intracomment_strip -->
449-
*/
450-
@Deprecated // MOE:strip_line
440+
/** Calculate the difference between two timestamps. */
451441
public static Duration between(Timestamp from, Timestamp to) {
452442
checkValid(from);
453443
checkValid(to);
@@ -456,18 +446,7 @@ public static Duration between(Timestamp from, Timestamp to) {
456446
checkedSubtract(to.getNanos(), from.getNanos()));
457447
}
458448

459-
/**
460-
* Add a duration to a timestamp.
461-
*
462-
* <!-- MOE:begin_intracomment_strip -->
463-
* @deprecated Do not use this method for new code. Instead, convert to {@link java.time.Instant}
464-
* and {@link java.time.Duration} using {@link
465-
* com.google.protobuf.util.JavaTimeConversions#toJavaInstant} and {@link
466-
* com.google.protobuf.util.JavaTimeConversions#toJavaDuration}, do the arithmetic there, and
467-
* convert back using {@link com.google.protobuf.util.JavaTimeConversions#toProtoTimestamp}.
468-
* <!-- MOE:end_intracomment_strip -->
469-
*/
470-
@Deprecated // MOE:strip_line
449+
/** Add a duration to a timestamp. */
471450
public static Timestamp add(Timestamp start, Duration length) {
472451
checkValid(start);
473452
Durations.checkValid(length);
@@ -476,18 +455,7 @@ public static Timestamp add(Timestamp start, Duration length) {
476455
checkedAdd(start.getNanos(), length.getNanos()));
477456
}
478457

479-
/**
480-
* Subtract a duration from a timestamp.
481-
*
482-
* <!-- MOE:begin_intracomment_strip -->
483-
* @deprecated Do not use this method for new code. Instead, convert to {@link java.time.Instant}
484-
* and {@link java.time.Duration} using {@link
485-
* com.google.protobuf.util.JavaTimeConversions#toJavaInstant} and {@link
486-
* com.google.protobuf.util.JavaTimeConversions#toJavaDuration}, do the arithmetic there, and
487-
* convert back using {@link com.google.protobuf.util.JavaTimeConversions#toProtoTimestamp}.
488-
* <!-- MOE:end_intracomment_strip -->
489-
*/
490-
@Deprecated // MOE:strip_line
458+
/** Subtract a duration from a timestamp. */
491459
public static Timestamp subtract(Timestamp start, Duration length) {
492460
checkValid(start);
493461
Durations.checkValid(length);

0 commit comments

Comments
 (0)