Print out the result of getChronology() for both, and see if they are equal. I suspect they are different (equals depends on the chronology - a design flaw in Joda-Time). Stephen
On 27 June 2012 02:51, John Hanks <jhanks9...@gmail.com> wrote: > I was surprised when I was using the equals() method of the LocalDate class. > > It was not behaving as I would expect. > > Take a look at the code below: > > DateTimeFormatter dateTimeFormat = DateTimeFormat.forPattern("yyyyMMdd > HH:mm"); > Calendar calendar = dateTimeFormat.parseDateTime("20120621 > 09:00").toCalendar(null); > LocalDate localDate1 = new LocalDate(calendar); > LocalDate localDate2 = new LocalDate(2012,6,21); > System.out.println(localDate1); > System.out.println(localDate2); > System.out.println("equals(): " + localDate1.equals(localDate2)); > System.out.println("isEqual(): " + localDate1.isEqual(localDate2)); > > > The output is: > > 2012-06-21 > 2012-06-21 > equals(): false > isEqual(): true > > > Why is the equals method comparison false. > > Is this not a Joda bug? > > P.S. I'm using Joda 2.1 > > > > > ------------------------------------------------------------------------------ > Live Security Virtual Conference > Exclusive live event will cover all the ways today's security and > threat landscape has changed and how IT managers can respond. Discussions > will include endpoint security, mobile security and the latest in malware > threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ > _______________________________________________ > Joda-interest mailing list > Joda-interest@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/joda-interest > ------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ _______________________________________________ Joda-interest mailing list Joda-interest@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/joda-interest