I am trying to convert the following string (Input: 2020-06-01-02.55.44.258554
) to timestamp.
I cannot use simpledateformat
with the following format yyyy-MM-dd-HH.mm.ss.SSSSSS
because it gives this result (2020-06-01-03.00.02.000554
) which is not correct.
How do I do it ?
CODE FOR YOUR REFERENCE :
String oldPattern = "yyyy-MM-dd-HH.mm.ss.SSSSSS", newPattern = "yyyy-MM-dd-HH.mm.ss.SSSSSS";
SimpleDateFormat sdf = new SimpleDateFormat(oldPattern);
Date date = sdf.parse("2020-06-01-02.55.44.258554");
sdf.applyPattern(newPattern);
String NEWDATE = sdf.format(date).toUpperCase();