Incrementing a java.util.Date by one day

前端 未结 8 1050

What is the correct way to increment a java.util.Date by one day.

I\'m thinking something like

        Calendar cal = Calendar.getInstance();
        ca         


        
8条回答
  •  爱一瞬间的悲伤
    2021-02-07 01:46

    Date thisDate = new Date(System.currentTimeMillis());
    
    Date dayAfter = new Date(thisDate.getTime() + TimeUnit.DAYS.toMillis( 1 ));
    
    Date dayBefore = new Date(thisDate.getTime() + TimeUnit.DAYS.toMillis( -1 ));
    

提交回复
热议问题