java - Joda DateTime equals vs isEqual -


i've got 2 similar dates , doubtful comparison joda datetime api provides:

log.info("comparing:"+abrdatetime+": , :"+breakstart+":"+abrdatetime.equals(breakstart)); 

this prints

comparing:2015-07-14t12:25:47.000+05:30: , :2015-07-14t12:25:47.000+05:30:false 

while datetime.isequal

log.info("comparing:"+abrdatetime+": , :"+breakstart+":"+abrdatetime.isequal(breakstart)); 

prints:

comparing:2015-07-14t12:25:47.000+05:30: , :2015-07-14t12:25:47.000+05:30:true 

problem i'm using datetime.equals method everywhere in app, should change isequal?

note: both instances got same same millis , same timezone can see in prints.

first, may need check code, because snippets give printing same object (which abrdatetime), yet, in equals , isequal method, compare abrdatetime breakstart object.

second, @ time this, best way check api documentation. equals, doc state :

compares object specified object equality based on millisecond instant, chronology , time zone

and isequal, doc state :

is instant equal instant passed in comparing solely millisecond

so, choice , want check time based on time? go isequal method. or, if want check timezone , chronology, go equals


edit:

addressing comment,

  1. chronology , why it's needed compare => taken doc

    chronology provides access individual date time fields chronological calendar system.

    therefore, can think chronology class contain date , time fields specific calendar system. (such as, iso, gregorian, buddhist, etc.)

    it needed, because don't want compare 2 date in different calendar system. example, let say, in islamic calendar system, first of june in gregorian 14 sha`baan (this opinion might different api author intended reason not documented)

  2. if want compare mills , time zone. guess use isequal method.


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

jquery - javascript onscroll fade same class but with different div -