如何解析三个DateTIme
How to parse threeten DateTIme
我正在尝试解析这个日期时间:
DateTimeFormatter dateTimeFormatter = new DateTimeFormatterBuilder()
.appendPattern("dd/MM/yyyy hh:mm:ss")
.parseDefaulting(ChronoField.SECOND_OF_MINUTE, 0)
.parseDefaulting(ChronoField.MILLI_OF_SECOND, 0)
.toFormatter();
String ultimaAtualizacaoTexto = "17/12/2016 01:41:43";
LocalDateTime ultimaAtualizacaoDateTime =
LocalDateTime.parse(ultimaAtualizacaoTexto, dateTimeFormatter);
但是我收到这个错误:
DateTimeParseException: Text '17/12/2016 01:41:43' could not be parsed: Unable to obtain LocalDateTime from TemporalAccessor: DateTimeBuilder[fields={MilliOfSecond=0, MinuteOfHour=41, MicroOfSecond=0, NanoOfSecond=0, HourOfAmPm=1, SecondOfMinute=43}, ISO, null, 2016-12-17, null], type org.threeten.bp.format.DateTimeBuilder
我不确定发生了什么......它应该完全有效!
有什么帮助吗?无论如何谢谢!
所以...我不得不将 "dd/MM/yyyy hh:mm:ss" 更改为 "dd/MM/yyyy HH:mm:ss"
因为 hh 只有 12 am/pm 小时。 HH 为 24 小时。
我正在尝试解析这个日期时间:
DateTimeFormatter dateTimeFormatter = new DateTimeFormatterBuilder()
.appendPattern("dd/MM/yyyy hh:mm:ss")
.parseDefaulting(ChronoField.SECOND_OF_MINUTE, 0)
.parseDefaulting(ChronoField.MILLI_OF_SECOND, 0)
.toFormatter();
String ultimaAtualizacaoTexto = "17/12/2016 01:41:43";
LocalDateTime ultimaAtualizacaoDateTime =
LocalDateTime.parse(ultimaAtualizacaoTexto, dateTimeFormatter);
但是我收到这个错误:
DateTimeParseException: Text '17/12/2016 01:41:43' could not be parsed: Unable to obtain LocalDateTime from TemporalAccessor: DateTimeBuilder[fields={MilliOfSecond=0, MinuteOfHour=41, MicroOfSecond=0, NanoOfSecond=0, HourOfAmPm=1, SecondOfMinute=43}, ISO, null, 2016-12-17, null], type org.threeten.bp.format.DateTimeBuilder
我不确定发生了什么......它应该完全有效!
有什么帮助吗?无论如何谢谢!
所以...我不得不将 "dd/MM/yyyy hh:mm:ss" 更改为 "dd/MM/yyyy HH:mm:ss"
因为 hh 只有 12 am/pm 小时。 HH 为 24 小时。