Java implementation to get before and after N day date function share
- 2020-04-01 03:48:16
- OfStack
The code is simple, the functionality is practical, and there's no more nonsense here.
public Date getdate(int i) // // Get before and after dates i Is positive Backward delayed i Days, negative Numbers move forward i day
{
Date dat = null;
Calendar cd = Calendar.getInstance();
cd.add(Calendar.DATE, i);
dat = cd.getTime();
SimpleDateFormat dformat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Timestamp date = Timestamp.valueOf(dformat.format(dat));
return date;
}
The above code is all the content of this article, hope you can enjoy it.
Please take a moment to share the article with your friends or leave a comment. We sincerely appreciate your support!