Here is my code in Java 1.6 (question was marked duplicate but suggested solution refers to java 1.8)
public static void main(String[] args){
try{
String dateTimeString = "2015-08-10-14.20.40.679279";
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd-HH.mm.ss.SSSSSS");
java.util.Date formattedDate = dateFormat.parse(dateTimeString);
Timestamp formattedTime = new Timestamp(formattedDate.getTime());
System.out.println(formattedTime);
} catch (Throwable t){
t.printStackTrace();
}
}
The resulted object is: 2015-08-10 14:31:59.279
, so clearly something is wrong while parsing minutes, seconds and millis, I just don't know what exactly.
Thank you!
There is no something like SSSSSS. Check Simple Date Format manual