Painless String to Date


(Krishna Chaitanya) #1

Hi,

Trying to convert String to Date in Painless

Painless Code:

LocalDateTime.parse(item.to_as_string, DateTimeFormatter.ISO_DATE)

Resulting in following error:

ScriptException[runtime error]; nested: DateTimeParseException[Text '2017-06-01' could not be parsed: Unable to obtain LocalDateTime from TemporalAccessor: {},ISO resolved to 2017-06-01 of type java.time.format.Parsed]; nested: DateTimeException[Unable to obtain LocalDateTime from TemporalAccessor: {},ISO resolved to 2017-06-01 of type java.time.format.Parsed]; nested: DateTimeException[Unable to obtain LocalTime from TemporalAccessor: {},ISO resolved to 2017-06-01 of type java.time.format.Parsed]; "

ISO_DATE supports 'yyyy-MM-dd' format.

If this way of converting string to date doesn't work, is there any other simple way?

Any help appreciated !!


(system) #2

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.