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

前端 未结 28 1794

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:26

    SimpleDateFormat dateFormat = new SimpleDateFormat( "yyyy-MM-dd" );
    Calendar cal = Calendar.getInstance();
    cal.setTime( dateFormat.parse( inputString ) );
    cal.add( Calendar.DATE, 1 );
    

提交回复
热议问题