Possible Duplicate:
How can I calculate a time span in Java and format the output?
Is there a simple function to format time range as a string? At the moment I can generate an output like that:
"81 days"
final Calendar today = Calendar.getInstance();
int today_day = today.get(Calendar.DAY_OF_YEAR);
final Calendar startCal = Calendar.getInstance();
startCal.add(Calendar.Day_OF_YEAR,81);
int start_day = startCal.get(Calendar.DAY_OF_YEAR);
int dif= start_day-today_day;
if (dif >1){
str = "in "+dif+" days";
}
but I would prefere it to be
" 2 month and 20 days"