1
I get a Date String like this:
2017-10-11 10:39:04.217923
I take that number off after the point, and I use the LocalDateTime.parse()
:
private final String PATTERN_DATA_HORA = "dd/MM/yyyy HH:mm:ss";
[...]
Movimentacao movimentacao = new Movimentacao();
StringTokenizer stringTokenizer = new StringTokenizer(movimentos.getJSONObject(i).get("dt_andamento_pa").toString());
movimentacao.setData(LocalDateTime.parse(stringTokenizer.nextToken("."), DateTimeFormatter.ofPattern(PATTERN_DATA_HORA)).atOffset(ZoneOffset.UTC));
I have the following error in parse:
Text
2017-10-11 10:39:04
could not be Parsed at index 2.
Note: I have seen similar situations in gringos forums, but the error continues. What to do?
That one .217923 It’s a type of data designed to be accurate in nanoseconds. And if you parse in every string what happens, without taking the milliseconds in case?
– Marcos Henzel
Gives same error: java.time.format.Datetimeparseexception: Text '2017-10-11 10:39:04.217923' could not be Parsed at index 2
– laaf