如何在Java日期中添加x天?
例如,我的日期是(dd / mm / yyyy)= 01/01/2019
(dd / mm / yyyy)= 01/01/2019
加5天,输出应为06/01/2019。
06/01/2019
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy"); Calendar c = Calendar.getInstance(); c.setTime(new Date()); // Now use today date. c.add(Calendar.DATE, 5); // Adding 5 days String output = sdf.format(c.getTime()); System.out.println(output);