one month after start date-joda

梦想与她 提交于 2020-01-04 14:12:57

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!