I'm using the conversion logic as below to convert an incoming string into date. But, the 'time' part is not getting converted properly in the output. Please find below the code and output.
String inputDate ="2016-04-22-00.56.03.389289";
System.out.println(inputDate);
String frmFormat = "yyyy-MM-dd-HH.mm.ss.SSSSSS";
String toFormat = "yyyy-MM-dd HH:mm:ss:SSSSSS";
DateFormat from = new SimpleDateFormat(frmFormat);
DateFormat to = new SimpleDateFormat(toFormat);
try {
Date date = from.parse(inputDate);
System.out.println("New date:" + to.format(date));
} catch (Exception e) {
e.printStackTrace();
}
OUTPUT: New date:2016-04-22 01:02:32:000289
Please help me to get the right output.