1 //获取时间加一年或加一月或加一天 2 Date date = new Date(); 3 Calendar cal = Calendar.getInstance(); 4 cal.setTime(date);//设置起时间 5 //System.out.println("111111111::::"+cal.getTime()); 6 //cal.add(Calendar.YEAR, 1);//增加一年 7 //cal.add(Calendar.DATE, 1);//增加一天 8 //cal.add(Calendar.DATE, -10);//减10天 9 //cal.add(Calendar.MONTH, 1);//增加一个月 10 SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); 11 System.out.println("当前时间:" + sdf.format(cal.getTime())); 12 //System.out.println("输出::"+cal.getTime());