java实现,如何在当前时间往后推N天

调用 getAfterDay 传入后推的天数,就能获取到当前时间往后推N天的时间

    public static Date asDate(LocalDateTime localDateTime) {
        return Date.from(localDateTime.atZone(ZoneId.systemDefault()).toInstant());
    }

    public static Date getAfterDay(int afterDay) {
        LocalDateTime localDateTime = LocalDateTime.now().plusDays(afterDay);
        return asDate(localDateTime);
    }

你可能感兴趣的:(工具类,java)