Sunday, 15 July 2012

jodatime - How to use joda time to achieve sql date format and to calculate years -



jodatime - How to use joda time to achieve sql date format and to calculate years -

i have mysql db , dates stored in using sql format of yyyy-mm-dd using jcalender gui customers dob in java swing.

how utilize calculate age of person using yearsbetween() in joda time , convert int.

please help, code useful :)

okay post code causing problem

string dob = "1965-02-03"; datetime today = new datetime(datetime.now().tolocaldate().tostring()); datetime start = new datetime(dob); system.out.println(today); system.out.println(dob); years y= years.yearsbetween(start, today); system.out.println(y);

why y homecoming value of p485 instead of right value?

your sysout on class years missing "getyears( )".

the code should this:

final string dob = "1965-02-03"; final datetime today = localtime.now().todatetimetoday(); final datetime start = datetime.parse(dob); system.out.println(today); system.out.println(dob); final years y = years.yearsbetween(start, today); system.out.println(y.getyears());

date jodatime

No comments:

Post a Comment