JAVA实现指定日期加几天

 /**
     * 日期增加一天
     * @param today 日期str
     * @return 加上几天后的日期
     */
    private String addOneday(String today, int i) {
        SimpleDateFormat f = new SimpleDateFormat("yyyy-MM-dd");
        try {
            Date d = new Date(f.parse(today).getTime() + 24 * 3600 * 1000 * i);
            return f.format(d);
        } catch (Exception ex) {
            return today;
        }
    }

posted @ 2020-05-07 20:23  一个小bu⑥  阅读(3350)  评论(0编辑  收藏  举报