I’m a beginner in java/android but I am trying to make an app. A user must type in a time like 13:45 and then the app should substrat ex. 00:30 minutes from that time. That gives the result 13:15.
I have tried many different things but it wont work.
I have somthing like this. (At this stage I’ve hardcoded two times)
String time1 = "00:30";
String time2 = "13:45";
SimpleDateFormat format = new SimpleDateFormat("HH:mm");
Date date1 = format.parse(time1);
Date date2 = format.parse(time2);
long result= date2.getTime() - date1.getTime();
String strLong = Long.toString(result);
textView4.setText(strLong);
I’m getting an error in the format.parse(time1) and format.parse(time2). Is this the right way to do this? Any help? Thanks
Use
Calendartype.