java - Trying to find the difference in days with JodaTime -
simply, i'm storing 'initial date' data string variable in text file e.g. 02-02-2015, , need know if 3 days has passed initial date. i've been recommended use jodatime kept on recieving errors i'm presuming because i'm comparing string , int variables.
is possible, if how? in advance?
edit: apologies didn't post code.
public void startdelay() { datetime dt = new datetime(); datetimeformatter fmt = datetimeformat.forpattern("dd-mm-yyyy"); delaypin = fmt.print(dt); } public int delayended() { datetime dt = new datetime(); datetimeformatter fmt = datetimeformat.forpattern("dd-mm-yyyy"); string today = fmt.print(dt); delayprogress = days.daysbetween(new datetime(delaypin), new datetime(today)).getdays(); return delayprogress; }
delaypin being stored in text file. repeated method todays date within second delayended method.
something this?
string storeddatestring = "02-02-2015"; datetimeformatter format = new datetimeformatterbuilder().appendpattern("mm-dd-yyyy").toformatter(); boolean isthreedayspassed = localdate.now().minusdays(3).isafter(localdate.parse(storeddatestring, format));
Comments
Post a Comment