Skip to content

Commit

Permalink
[CLEANUP] Replace the deprecated method in RelativeTimeUtil (apache#1…
Browse files Browse the repository at this point in the history
…4308)

### Modifications
- Replace the deprecated method in RelativeTimeUtil
- fix a typo
  • Loading branch information
hezhangjian authored Feb 16, 2022
1 parent 244060a commit c8d2410
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
package org.apache.pulsar.common.util;

import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.concurrent.TimeUnit;
import lombok.experimental.UtilityClass;

Expand All @@ -29,7 +30,7 @@
public class RelativeTimeUtil {
public static long parseRelativeTimeInSeconds(String relativeTime) {
if (relativeTime.isEmpty()) {
throw new IllegalArgumentException("exipiry time cannot be empty");
throw new IllegalArgumentException("expiry time cannot be empty");
}

int lastIndex = relativeTime.length() - 1;
Expand Down Expand Up @@ -73,6 +74,6 @@ public static long parseRelativeTimeInSeconds(String relativeTime) {
public static double nsToSeconds(long ns) {
double seconds = (double) ns / 1_000_000_000;
BigDecimal bd = new BigDecimal(seconds);
return bd.setScale(3, BigDecimal.ROUND_HALF_UP).doubleValue();
return bd.setScale(3, RoundingMode.HALF_UP).doubleValue();
}
}

0 comments on commit c8d2410

Please sign in to comment.