Friday, 15 May 2015

datetime - How to find difference between two dates which is in string format in android -



datetime - How to find difference between two dates which is in string format in android -

calendar zcalendarl = calendar.getinstance(); simpledateformat zdateformatl = new simpledateformat("yyyy/mm/dd hh:mm:ss"); string datetime="2013/02/15 15:05:01"; string zupdateddatetimeg =zdateformatl.format(datetime); string zcurrentdatetimel=zdateformatl.format(zcalendarl.gettime());

i need know date time between zcurrentdatetimel , zupdateddatetimeg

how it?

try this: hope help worked me...

private void getdifference(java.util.date starttime, java.util.date endtime, java.util.date eartime, java.util.date curtime) { calendar startdatetime = calendar.getinstance(timezone .gettimezone("gmt-5:00")); startdatetime.settime(starttime); calendar enddatetime = calendar.getinstance(); enddatetime.settime(endtime); long milliseconds1 = startdatetime.gettimeinmillis(); long milliseconds2 = enddatetime.gettimeinmillis(); long diff = math.abs(milliseconds1 - milliseconds2); long seconds = diff / (1000); }

android datetime

No comments:

Post a Comment