0

I'm making an app that will calculate a date between the current phone date and a new date that depends on user input.

Example: newDate = current(20/5) + months(3)

So newDate should be 20/8.

And I need a way to store newDate into my database too. Please help it's for my failing final year project T.T

Sagar Zala
  • 4,854
  • 9
  • 34
  • 62

1 Answers1

1

You can use Calendar class to do your job,

How? check out below,

Calendar cal = Calendar.getInstance(TimeZone.getDefault(), Locale.getDefault());
cal.setTime(currentDate); // pass your current Date class instance
cal.set(Calendar.MONTH, cal.get(Calendar.MONTH) + 3); // Now use this calendar to add 3 months to add in your current date.
cal.getTime(); // Now get date of 3 months after
Jeel Vankhede
  • 11,592
  • 2
  • 28
  • 58