I\'m working with a date in this format: yyyy-mm-dd
.
How can I increment this date by one day?
If you are using Java 8, java.time.LocalDate
and java.time.format.DateTimeFormatter
can make this work quite simple.
public String nextDate(String date){
LocalDate parsedDate = LocalDate.parse(date);
LocalDate addedDate = parsedDate.plusDays(1);
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-mm-dd");
return addedDate.format(formatter);
}