You can try something like this,
String dt = "2012-01-04"; // Start date
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Calendar c = Calendar.getInstance();
try {
c.setTime(sdf.parse(dt));
} catch (ParseException e) {
e.printStackTrace();
}
c.add(Calendar.DATE, 40); // number of days to add, can also use Calendar.DAY_OF_MONTH in place of Calendar.DATE
SimpleDateFormat sdf1 = new SimpleDateFormat("MM-dd-yyyy");
String output = sdf1.format(c.getTime());
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…