date - How to add part of time in Android -
i have code returning me string (hh:mm).
simpledateformat curformater = new simpledateformat("yyyy-mm-dd hh:mm:ss"); java.util.date dateobj; try { dateobj = curformater.parse(start); simpledateformat postformater = new simpledateformat("hh:mm"); string newdatestr = postformater.format(dateobj); startview.settext(newdatestr); emission_start = newdatestr; } catch (parseexception e) { // todo auto-generated catch block log.d(" * error", e.tostring()); } it works great... right to:
- add x (is dynamically provided) minutes (x = 5 1000 minutes) , transform time (example time:3:45, add 25 minutes, transform time 4:10)
- get current time , calculate difference between current time , time step 1 (4:10)
- get time difference (from step 2) in minutes!
thanks help!
i haven't tested, should work:
long newdate = dateobj.gettime() + (x * 60 * 1000)long diff = system.currenttimemillis() - newdatedouble diffinmins = diff / (60.0 * 1000.0)
Comments
Post a Comment