Back
This is very simple, just use a syntax like this one:
String dt = "2019-07-12"; // Start dateSimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");Calendar c = Calendar.getInstance();c.setTime(sdf.parse(dt));c.add(Calendar.DATE, 1); // number of days to adddt = sdf.format(c.getTime()); // dt is now the new date
String dt = "2019-07-12"; // Start date
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Calendar c = Calendar.getInstance();
c.setTime(sdf.parse(dt));
c.add(Calendar.DATE, 1); // number of days to add
dt = sdf.format(c.getTime()); // dt is now the new date
You can read about it here.
We can increment date by one day in java using 2 different approaches:
1.2k questions
2.7k answers
501 comments
693 users