Skip to content

How to increment date by one day in Java?

The following code snippet written in Java lets you increment date by any number of days. Just make sure you use the right date structure in Java.

String date = "2019-09-12";  // Your date
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Calendar calendar = Calendar.getInstance();
calendar.add(Calendar.DATE, 1);  // number of days to add to your existing date
date = sdf.format(calendar.getTime());  // date is now the new date
See also  Different ways of converting Array to ArrayList() in Java

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.