I am having this string 00 hours 01 minutes 25 seconds stored in variable . How can I convert it into 00:01 hour and minutes in Java
what I tried is:
String s = "00 hours 01 minutes 25 seconds";
System.out.println(s);
String []a = s.split(" , ");
String s2 = a[0] + a[2];
newis not valid variable name - it is a reserved keyword. 2. You use wrong regex to split your string. Use s.split(" ") instead