计算某天n月之后的日期

public static java.util.Date getBeforeAfterDateMonth(Date date, int month) {  
       
        Calendar cal = new GregorianCalendar();  
        cal.setTime(date);  
  
        int Year = cal.get(Calendar.YEAR);  
        int Month = cal.get(Calendar.MONTH);  
        int Day = cal.get(Calendar.DAY_OF_MONTH);  
  
        int NewMonth = Month + month;  
  
        cal.set(Calendar.YEAR, Year);  
        cal.set(Calendar.MONTH, NewMonth);  
        cal.set(Calendar.DAY_OF_MONTH, Day);  
  
        return new Date(cal.getTimeInMillis());  
    }

发布了87 篇原创文章 · 获赞 22 · 访问量 19万+

猜你喜欢

转载自blog.csdn.net/gaofenglxx/article/details/60139933