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:

  1. add x (is dynamically provided) minutes (x = 5 1000 minutes) , transform time (example time:3:45, add 25 minutes, transform time 4:10)
  2. get current time , calculate difference between current time , time step 1 (4:10)
  3. get time difference (from step 2) in minutes!

thanks help!

i haven't tested, should work:

  1. long newdate = dateobj.gettime() + (x * 60 * 1000)

  2. long diff = system.currenttimemillis() - newdate

  3. double diffinmins = diff / (60.0 * 1000.0)


Comments

Popular posts from this blog

php - What is the difference between $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']? -

fortran - Function return type mismatch -

queue - mq_receive: message too long -