Subtracting 1 day from date...

All, I am displaying the current date

new java.text.SimpleDateFormat("yyyy-MM-dd").format (new java.util.Date ());

I want to display current date - 1 and/or +1.

How?
greedy1Asked:
Who is Participating?
 
CEHJConnect With a Mentor Commented:
Calendar cal = Calendar.getInstance();
cal.setTime(yourDate);
cal.add(Calendar.DATE, -1);
String newDate = yourFormat.format(cal.getTime());
0
 
CEHJCommented:
8-)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.