Say I have 203 days. I want to convert that number to the string x months y days
from today. How do I do that using joda time? (of course 203 is just an example, use z if that helps.)
EDIT: Working out the period starting at a particular date is pretty easy with Joda Time. For example:
public Period getMonthsAndDays(int days, LocalDate start) {
LocalDate end = start.plusDays(days);
return new Period(start, end, PeriodType.yearMonthDay().withYearsRemoved());
}
You can then call Period.getDays()
and Period.getMonths()
. Just pass in today's date in the relevant time zone (which you need to consider) and you're away.
See more on this question at Stackoverflow