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

前端 未结 28 1785

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 06:59

    Please note that this line adds 24 hours:

    d1.getTime() + 1 * 24 * 60 * 60 * 1000
    

    but this line adds one day

    cal.add( Calendar.DATE, 1 );
    

    On days with a daylight savings time change (25 or 23 hours) you will get different results!

提交回复
热议问题