通過給定的秒級時間戳,來算出n天后的時間戳,或者是字符串
java8之前的時間api存在閏秒問題,所以如果要獲取到準確的時間戳,最好用java8api,不要用當前時間戳加上每天的秒數來算.
private String getDelayDaysString(Long stratTime, Integer n) {
LocalDateTime localDateTime = LocalDateTime.ofInstant(Instant.ofEpochSecond(stratTime), getChinaZone());
LocalDateTime time = localDateTime.plusDays(n);
return time.toString();
}
private static ZoneOffset getChinaZone() {
return ZoneOffset.of("+8");
}