I have a code returning me a 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… But right now I would like to:
- add x (is dynamically provided) minutes (x = from 5 to 1000 minutes) and transform to time (example time:3:45, add 25 minutes, transform to time 4:10)
- Get current time and calculate difference between current time and time from step 1 (4:10)
- Get time difference (from step 2) in minutes!
Thanks for your help!
I haven’t tested, but something like this should work:
long newDate = dateObj.getTime() +(x * 60 * 1000)
long diff =System.currentTimeMillis() - newDate
double diffInMins = diff / (60.0 * 1000.0)