-2

I have different dates in my program like 08-Mar-2017. How can I get next or previous date from this specified date?

Sameh Akbari
  • 17
  • 1
  • 1
  • 4

1 Answers1

2
Calendar cal = Calendar.getInstance();
cal.setDate(your date);
cal.add(Calendar.DAY_OF_MONTH, 1);

You have to convert the string into date and set it to calendar and then you can add a day and to remove

cal.add(Calendar.DAY_OF_MONTH, -1);
Arpan Sharma
  • 2,142
  • 11
  • 22