How can I increment a date by one day in Java?

前端 未结 28 1778

I\'m working with a date in this format: yyyy-mm-dd.

How can I increment this date by one day?

28条回答
  •  一生所求
    2020-11-21 07:22

    Take a look at Joda-Time (https://www.joda.org/joda-time/).

    DateTimeFormatter parser = ISODateTimeFormat.date();
    
    DateTime date = parser.parseDateTime(dateString);
    
    String nextDay = parser.print(date.plusDays(1));
    

提交回复
热议问题