You need to write one of the following:
Period period = new Period(start, end, PeriodType.days());
int days = period.getDays();
Days period = Days.daysBetween(start, end);
Stephen
Elam Daly wrote:
> Hi all,
>
> I'm trying this simple example to understand the Period class.
>
> Why does the
The Period class divides the given period over its different fields (years,
months, weeks...). So your period will return 1 for both the getYears and
the getWeeks method as the given period of between start and end date exist
of exactly one year and one week. Therefore the getDays method will retur
DateTime start = new DateTime(2004, 12, 25, 0, 0, 0, 0);
DateTime end = new DateTime(2006, 1, 1, 0, 0, 0, 0);
Interval interval = new Interval(start, end);
System.out.println(Days.
daysIn(interval).getDays()); // prints 372
On Tue, Sep 30, 2008 at 10:50 AM, Elam Daly <[EMAIL PROTECTED]> wrote:
>
] Misunderstanding Period Class.
Well, using this particular example, all the toStandardXXX methods are
throwing exceptions because of the presence of years in the Period, as the
Javadocs state. So is there a way around this, ie to convert a period of
months/years into minutes/hours etc?
Thanks,
- Elam
Actually, what I'm trying to do is, given two DateTime instances, I need to
calculate the number of minutes/hours/seconds etc between the two. After
looking over the mailing list, it looks like I can simply use the
XXX.xxxBetween(DateTime one, DateTime two) methods.
Is this a reasonable solution?
Use
Period period = new Period(start, end, PeriodType.days());
Stephen
2008/9/30 Elam Daly <[EMAIL PROTECTED]>:
> Hi all,
>
> I'm trying this simple example to understand the Period class.
>
> Why does the getDays() method return 0, instead of 472?
>
> Thanks,
> - Elam
>
> DateTime start = new D
Well, using this particular example, all the toStandardXXX methods are
throwing exceptions because of the presence of years in the Period, as the
Javadocs state. So is there a way around this, ie to convert a period of
months/years into minutes/hours etc?
Thanks,
- Elam
On Tue, Sep 30, 2008 at 1
Because the getXXX methods just return that FIELD of time. If you want the
computed time, you need the toStandardXXX method.
On Tue, Sep 30, 2008 at 9:41 AM, Elam Daly <[EMAIL PROTECTED]> wrote:
> Hi all,
>
> I'm trying this simple example to understand the Period class.
>
> Why does the getDays
Hi all,
I'm trying this simple example to understand the Period class.
Why does the getDays() method return 0, instead of 472?
Thanks,
- Elam
DateTime start = new DateTime(2004, 12, 25, 0, 0, 0, 0);
DateTime end = new DateTime(2006, 1, 1, 0, 0, 0, 0);
// period of 1 year and 7 days
Period peri