你可以Date像这样在 Java 中格式化 s:
String str = "12/12/2012 5:35 PM"; //Your String containing a date
DateFormat dF = new SimpleDateFormat("dd//MM/yyyy hh:mm a"); // The mask
// 'a' value in the Mask represents AM / PM - h means hours in AM/PM mode
Date date = dF.parse(str); // parsing the String into a Date using the mask
//Date.getTime() method gives you the Long with milliseconds since Epoch.
System.out.println("Epoch representation of this date is: " + date.getTime());
Run Code Online (Sandbox Code Playgroud)
请参阅此掩码选项:http://docs.oracle.com/javase/1.5.0/docs/api/java/text/SimpleDateFormat.html