I have one incoming string which is in this format, "20210526T150239", double quotes signify that this is String.
How to convert it into something in this format 2021-05-06T12:56:21.826?
After the T values in the 2021-05-26T12:56:21.826 is not exactly equal to 150239? But its clear I want the format to be changed in such a way that Hour value then : then minute value then : and second value then . and its followed by millisecond.
How to change the format in Java from 20210526T150239 to this format 2021-05-06T12:56:21.826?
I tried something like this
long unixSeconds = Long.parseLong(incomingTimeStamp);
Date date = new Date(unixSeconds * 1000L);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS");
sdf.setTimeZone(TimeZone.getTimeZone("GMT"));
incomingTimeStamp = sdf.format(date)
But the T in the string is causing problem, it can not be converted to Long just by multiplying with 1000L. How to do it in Java?