java - JODA time wrong values on each iteration -


i trying joda time in java using latest version 2.2 have written small snippet here code

public static void main(string[] args)  {     boilertester clazz = new boilertester();     calendar today = calendar.getinstance();     calendar born  = calendar.getinstance();     //when returns 0 10363 when returning 1 = 10362 millisecond have days??     system.out.println(math.abs(today.gettimeinmillis()-born.gettimeinmillis()));     born.set(1984,10,20);             clazz.compute(born,today); }    private void compute(calendar born, calendar today) {     system.out.println("joda:  " + org.joda.time.days.daysbetween(new org.joda.time.datetime(born.gettime()),new org.joda.time.datetime(today.gettime())).getdays());     } 

when run source code getting values

joda: 10363

later run same code , getting

joda: 10362

yes have run maybe 2 or 3 times same code different values why this???

thanks lot.

my guess sometimes, today , born dates on exact same millisecond, , differ few milliseconds (the time elapses between first call calendar.getinstance() , second one). since getdays() returns number of complete days, few milliseconds make difference.


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -