Hi,
I have a String in format hh:mm (e.g. 13:35) which I want to convert to milliseconds. Please suggest how to do that?
Thanks,
Printable View
Hi,
I have a String in format hh:mm (e.g. 13:35) which I want to convert to milliseconds. Please suggest how to do that?
Thanks,
is this the thing u are looking for !!
Code:import java.util.Scanner;
public class Sample {
public void getConverted(String s)
{
String[] c = s.split(":");
int hour = Integer.parseInt(c[0]);
int mint = Integer.parseInt(c[1]);
//Separeated and converted into integer.
System.out.println(hour);
System.out.println(mint);
/*do maths here to calculate the milliseconds.
*
*
*
*/
}
public static void main(String []args)
{
Sample s = new Sample();
s.getConverted("11:11");//passs any string from here.
}
}
dont pass aa:bb kind of things.. if passing prepare for NumberFormatException.Quote:
s.getConverted("11:11");//passs any string from here