I want to compare(finding remaining days and time between two days) using joda time.
I am taking two DateTime object like this(one is starting and another is ending)
DateTime endDate = new DateTime(2011,12,25,0,0,0,0);
DateTime strtDate = new DateTime();
Now i am interested to find remaining date and time like this
days:49 Hrs:5 Min:52 Sec:45(Not considering Year and month here..)
Now I go ahead with period class like this
Period period = new Period();
PeriodFormatter formatter = new PeriodFormatterBuilder()
.appendSeconds()
.appendMinutes()
.appendHours()
.appendDays()
.appendMonths()
.appendYears()
.printZeroNever()
.toFormatter();
Now in result what i get year,month,Day,etc…
in this case i will get days between 1-30(not 31,45,49…(which I want)) always.
So how can i get this thing(is there any method that I am missing) or I need to handle this programmatically, as I read that joda time is very flexible so I am very sure that there will be any method like this.
If you are familiar then kindly share your knowledge.
Defines all standard fields from days downwards with PeriodType.dayTime().
For example :
Sample output
Period between
startDateandendDateisOr
with output