I had assumed that a LocalDate object represents just a date (day/
month / year), independent of timezones and instants of time. So that,
if I create two LocalDates from different instants of time, those
instants (and perhaps timezones) might be used to "resolve" it to the
corresponding date, but afterwards that info is discarded.
Hence, I had the confidence that two LocalDates d1,d2 that verify
d1.equals(d2) are actually the same object (no necessarily the same
object in memory, but totally equivalent in what respects to behaviour
and date calculations; they are the same "Date", aren't they?).
I seems I misunderstood something.
Below I give an example for which the "same" pair of dates throws
different daysBetween. This is the output I get:
days between: d0=2007-02-06 and dh=2007-02-21: 15
days between: d1=2007-02-06 and dh=2007-02-21: 14
days between: d1=2007-02-07 and dh=2007-02-21: 14
I wonder if is a a bug, or expected behaviour ?
Tested with joda 1.4 (Java 1.5, both in Windows and Linux)
Cheers
Hernán J. González
///////////////////////////////////////////////////////////////////////////////////////////////////
public static void main(String[] args) throws Exception {
long i1x = 1170817200000L - 10;
long i2x = i1x + 10;
LocalDate d0 = new LocalDate(2007, 2, 6);
LocalDate dh = new LocalDate(1172102400000L);
LocalDate dant = null;
System.out.println("days between: d0=" + d0 + " and dh=" + dh +
": "
+ Days.daysBetween(d0, dh).getDays());
for (long ix = i1x; ix <= i2x; ix++) {
LocalDate d1 = new LocalDate(ix);
if (dant != null && !d1.equals(dant)) {
System.out.println("days between: d1=" + dant +
" and dh=" + dh
+ ": " + Days.daysBetween(dant,
dh).getDays());
System.out.println("days between: d1=" + d1 + "
and dh=" + dh
+ ": " + Days.daysBetween(d1,
dh).getDays());
System.out.println("d1=" + d1 + " dh=" + dh + "
dant=" + dant
+ " ix=" + ix);
}
dant = d1;
}
}
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Joda-interest mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/joda-interest