Consider I have a value which i have to set as day in JodaTime
.
int new_day;
this is my day which I have to set as day in JodaTime
. I already have a time in JodaTime
object which is 2014-04-01T10:10:10.000+05:30
.
i want to set the date 01 to 15 and consider value of new_day = 15;
.
I want this 15 instead of 01 and the answer should be coming like this after changing.
2014-04-15T10:10:10.000+05:30
.
This is what i tried and not working
start=start.plusDays(new_day);
Thanks
If your start
variable is of time DateTime
, I suspect you want DateTime.withDayOfMonth
:
start = start.withDayOfMonth(new_day);
Other types (e.g. LocalDateTime
) have similar methods.
(I'd also advise you to start following Java naming conventions, using camelCasing instead of underscore_separation.)
See more on this question at Stackoverflow