3131
3232import static com .google .common .base .Preconditions .checkArgument ;
3333import static com .google .common .base .Preconditions .checkNotNull ;
34+ import static com .google .protobuf .util .Timestamps .add ;
35+ import static com .google .protobuf .util .Timestamps .fromMillis ;
3436import static com .google .protobuf .util .Timestamps .subtract ;
3537
3638/**
@@ -120,7 +122,7 @@ public static Timestamp getCurrentTime() {
120122 * @return current system time
121123 */
122124 public static Timestamp systemTime () {
123- return com . google . protobuf . util . Timestamps . fromMillis (System .currentTimeMillis ());
125+ return fromMillis (System .currentTimeMillis ());
124126 }
125127
126128 /**
@@ -162,7 +164,7 @@ public static void resetProvider() {
162164 private static class SystemTimeProvider implements Provider {
163165 @ Override
164166 public Timestamp getCurrentTime () {
165- final Timestamp result = com . google . protobuf . util . Timestamps . fromMillis (System .currentTimeMillis ());
167+ final Timestamp result = fromMillis (System .currentTimeMillis ());
166168 return result ;
167169 }
168170 }
@@ -274,12 +276,13 @@ public static long convertToNanos(TimestampOrBuilder timestamp) {
274276 }
275277
276278 private static class TimestampComparator implements Comparator <Timestamp >, Serializable {
279+
280+ private static final long serialVersionUID = 0 ;
281+
277282 @ Override
278283 public int compare (Timestamp t1 , Timestamp t2 ) {
279284 return Timestamps .compare (t1 , t2 );
280285 }
281-
282- private static final long serialVersionUID = 0 ;
283286 }
284287
285288
@@ -313,7 +316,9 @@ public static Timestamp secondsAgo(long value) {
313316 }
314317
315318 private static void checkPositive (long value ) {
316- checkArgument (value > 0 , "value must be positive" );
319+ if (value <= 0 ) {
320+ throw new IllegalArgumentException (String .format ("value must be positive. Passed: %d" , value ));
321+ }
317322 }
318323
319324 /**
@@ -326,7 +331,7 @@ private static void checkPositive(long value) {
326331 public static Timestamp secondsFromNow (int seconds ) {
327332 checkPositive (seconds );
328333 final Timestamp currentTime = getCurrentTime ();
329- final Timestamp result = com . google . protobuf . util . Timestamps . add (currentTime , Durations .ofSeconds (seconds ));
334+ final Timestamp result = add (currentTime , Durations .ofSeconds (seconds ));
330335 return result ;
331336 }
332337}
0 commit comments