问题
I have to call a method that needs two parameters begin date and end date and my end date is exactly one month after the begin date. I used this:
mymethod(startDate.toDate(), startDate.plusMonths(1));
but I got this error:
the method mymethod(Date, Date) is not applicable for the arguments (Date, DateTime)
Any idea how can I fix it?
回答1:
mymethod(startDate.toDate(), startDate.plusMonths(1));
should be:
mymethod(startDate.toDate(), startDate.plusMonths(1).toDate());
回答2:
The method mymethod()
seems to be declared with the datatypes Date as:
mymethod(Date, Date)
while the joda time method plusMonths returns a value of type DateTime
.
You can either change your method to work with DateTime
or change the DateTime
to Date
after adding one month using the toDate() function.
来源:https://stackoverflow.com/questions/17160974/one-month-after-start-date-joda