import java.util.ArrayList;
public class MyClass {
public static void main(String args[]) {
String str = "11:58:35";
ArrayList<String> time_parts = new ArrayList<String>();
int pos = 0;
while ((pos = str.indexOf(":", pos)) != -1) {
time_parts.add(str.substring(0, pos));
str = str.substring(pos + 1);
}
time_parts.add(str); // Add the seconds
if (time_parts.size() != 3) {
System.out.println("Invalid time format");
}
int hours = Integer.parseInt(time_parts.get(0));
int minutes = Integer.parseInt(time_parts.get(1));
int seconds = Integer.parseInt(time_parts.get(2));
System.out.println(hours + ":" + minutes + ":" + seconds);
}
}
/*
run:
11:58:35
*/