I get an exception when parsing a date 20160327020727with a format yyyyMMddhhmmss. Note that the softness parameter is set to false.
20160327020727
yyyyMMddhhmmss
SimpleDateFormat df = new SimpleDateFormat("yyyyMMddhhmmss"); df.setLenient(false); try { Date dt = df.parse("20160327020727"); } catch (ParseException e) { e.printStackTrace(); }
It processes other dates in the same format and works as expected. Why is this happening?
CET changes to summer time on the last Sunday of March, so there is no 2AM on this day.
You go from 1:59 to 3:00
You get an error because this time does not exist in your default time zone.
UTC, df.setTimeZone(TimeZone.getTimeZone("UTC"));
UTC
df.setTimeZone(TimeZone.getTimeZone("UTC"));
CET → No 2AM .
CET
Change it to "yyyyMMdd HHmmss"so you can easily disassemble it.
"yyyyMMdd HHmmss"
Source: https://habr.com/ru/post/1651806/More articles:How to add non-standard sql functions to spring boot application? - spring-bootWhich data type to choose json or jsonb or text - jsonFast generic function saved as varaible - genericsWhy are my missing JavaScript elements for the loop? - javascriptBest practice for many AJAX API calls requiring a response from a previous call? - javascriptGet current location from reaction-router-reduct - reactjsHow to guarantee referential transparency in F # applications? - functional-programmingЗадача собеседования - создать такую систему, как S3 - cachingPandas: Type conversion using `df.loc` from datetime64 to int - pythonHow to write python dictionary to excel file? - pythonAll Articles