Possible Duplicate:
how to convert java string to Date object
In my Java code I have input String like 05.10.2011
which I need to convert to milliseconds.
So:
String someDate = "05.10.2011";
I have to convert to match milliseconds format.
Possible Duplicate:
how to convert java string to Date object
In my Java code I have input String like 05.10.2011
which I need to convert to milliseconds.
So:
String someDate = "05.10.2011";
I have to convert to match milliseconds format.
String someDate = "05.10.2011";
SimpleDateFormat sdf = new SimpleDateFormat("MM.dd.yyyy");
Date date = sdf.parse(someDate);
System.out.println(date.getTime());
You can use Java's SimpleDateFormat to easily convert to a Date instance.
SimpleDateFormat formatter = new SimpleDateFormat("MM.dd.yyyy"); // Month.Day.Year
Date d = formatter.parse(inputString);
long timestamp = d.getTime();
use the simpleDateFormat which takes a string and converts it to Date then call the getTime() to get the date in milliseconds format