1

I want to get the date after x days from current. I am using java,util.Date in the code.

fun dateAfterXdays(x: Int) : Date{
   var date = Date()
    date.date = date.date + x
    return date
}

Is there a better way to do it

png
  • 4,368
  • 7
  • 69
  • 118
  • 1
    Does this answer your question? [Android get date before 7 days (one week)](https://stackoverflow.com/questions/3747490/android-get-date-before-7-days-one-week) Only there’s a sign you need to reverse. I recommend [the answer by Basil Bourque](https://stackoverflow.com/a/27728511/5772882), only use `plusDays()` instead of `minusWeeks()`. – Ole V.V. Sep 25 '20 at 20:56
  • Your code is not Java. What is it? You should probably tag your questions accordingly to attract those who know that programming language. – Ole V.V. Sep 27 '20 at 05:26

0 Answers0