I am trying to convert date from (ddmmyyyy HH:mm:ss) to (yyyy-MM-dd HH:mm:ss.SSS) format.
Below is the code :
String startDate="06162019 00:00:00";
SimpleDateFormat inSDF = new SimpleDateFormat("ddmmyyyy HH:mm:ss");
SimpleDateFormat outSDF = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
try{
String outDate = "";
Date date = inSDF.parse(startDate);
System.out.println(date);
outDate = outSDF.format(date);
System.out.println(outDate);
}catch (final Exception e) {
e.getMessage();
}
But i am getting wrong result :
Sun Jan 06 00:00:00 GMT 2019
2019-01-06 00:00:00.000
Any help would be appreciated?