将现有日期增加1天 [英] Increment existing date by 1 day
本文介绍了将现有日期增加1天的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个现有的日期对象,我想增加一天,同时保持每个其他字段是一样的。我遇到的每个例子都是几分钟/分钟/秒,或者你必须创建一个新的日期对象并传输这些字段。有没有办法可以将日期字段提前1?
I have an existing date object that I'd like to increment by one day while keeping every other field the same. Every example I've come across sheds hours/minutes/seconds or you have to create a new date object and transfers the fields over. Is there a way you can just advance the day field by 1?
谢谢
编辑:对不起,我没有'意味着将当天的价值增加1,我的意思是提前一天1
Sorry i didn't mean increment the value of the day by one, i meant advance the day forward by 1
推荐答案
Calendar c = Calendar.getInstance();
c.setTime(yourdate);
c.add(Calendar.DATE, 1);
Date newDate = c.getTime();
这篇关于将现有日期增加1天的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文