A first step will be to convert the time in HH:MM:SS format (which is how your string is formatted) to that of seconds as per the following:
String timerStop1 = String.format("%02d", hours) + ":" + String.format("%02d", minutes) + ":" + String.format("%02d", seconds);
String[] timef=timerStop1.split(":");
int hour=Integer.parseInt(timef[0]);
int minute=Integer.parseInt(timef[1]);
int second=Integer.parseInt(timef[2]);
int temp;
temp = second + (60 * minute) + (3600 * hour);
System.out.println("seconds " + temp);
However, this only gets the time as seconds (integers), but not as a timestamp!
UPDATE:
And, as Colin pointed out, given that you already have access to the variables: hours, minutes, seconds – why not do it like what he suggested – which is completely correct?
https://stackoverflow.com/a/15307211/866930
That’s because the OP wants to know how to convert an HH:MM:SS string to an integer – if so, then this is the most general way in which to do so, IMO.
6
solved How can I convert a datetime string into an integer datatype?