I'm trying to convert a utc date time in local date time, but I have some problem the the decimal fraction. I call a web service the return a series of data. One of these data is the utc date time in this format I must the use this library org.threeten.bp, I can't use a different library.
2020-06-22T18:28:57.957535800Z
To converte utcFormat to Date,I have found this piece of code that it works fine
DateFormat utcFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
utcFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
Date date = utcFormat.parse("2012-08-15T22:56:02.038Z");
DateFormat pstFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS");
pstFormat.setTimeZone(TimeZone.getTimeZone("ECT"));
System.out.println(pstFormat.format(date));
but it doesen't work well from my code, because return this date
2020-07-03T22:27:52.800
How you can see it's different. I did some test and if I leave only 3 decimal after dot, that part of code it will work fine. Have a look the example:
2020-06-22T18:28:57.800Z
return the right date time from ECT zone
2020-06-22T20:28:57.800
I am looking for a way to receive the utc dateTime with only three decimals or to change the utc dateTime by removing the excess decimals. With this last case I am not if it can be a good idea.