Mister M Mister M - 1 year ago 41
Java Question

how to add a single day to "dd/mm" format in java

I have a date in

format, I need to add a single day to this date, so it becomes

How can I do this in the easiest way in java?

Answer Source

You can use Calendar.

String dt = "15-07-2016";  
SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy");
Calendar c = Calendar.getInstance();
c.add(Calendar.DATE, 1);  // number of days to add
dt = sdf.format(c.getTime());