Calendar cal = Calendar.getInstance();
int year =cal.get(Calendar.YEAR)+1;
int month=cal.get(Calendar.MONTH)+1;
cal.add(Calendar.MONTH, 1);
//Date date = cal.getTime(); //结果
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
cal.set(Calendar.YEAR,cal.get(Calendar.YEAR)+1);
Date date=cal.getTime();
System.out.println(sdf.format(date));
时间: 2024-10-10 03:31:28