rkneal
asked on
Convert String MM/dd/yyyy hh:mm:ss to Milliseconds in Java
I need to know if there is a way to convert a string in MM/dd/yyyy hh:mm:ss format to its equivalent in milliseconds (Epoch time) in Java? I have a string in this format that I need to convert to milliseconds so I can send the converted value through my program that requires the time to be in this format. Any help would be appreciated.
Use the class SimpleDateFormat.
String date = "......";
SimpleDateFormat format = new SimpleDateFormat("MM/dd/yyyy hh:mm:ss");
Date d = format.parse(date);
long time = d.getTime();
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
String text = ... // Date text
Date date = new SimpleDateFormat("MM/dd/yy
long epoach = date.getTime();