DateUtil

1.得到指定的前N个月
    public static String getBeforeDateStr(int months)
    {

        Calendar calendar = Calendar.getInstance();
        int diff = (-1) * months;
        calendar.add(Calendar.MONTH, diff);
        Date date = calendar.getTime();
        SimpleDateFormat dataFormat = new SimpleDateFormat("yyyyMMddHHmmss");
        String dateStr = dataFormat.format(date);
        return dateStr;
    }

你可能感兴趣的:(Date)