I have to parse the time with format "yyyy-MM-dd HH:mm:ss.SSS" into a date time object . Any idea why the script1 is not working. I have tried many formatting options but none is working.
Are you manually entering values to String datetime ? Or this is just an example?
If not, where are the values coming from? Have samples of your raw data?
Cheers!
this is just an example. the values are coming from field doc[rtd.PARSER_TIME] of keyword data type. tried below script but empty array returned without any error.
it is still returning empty array. what I observed is your input string data must have a 'Z' at the end otherwise it is returning empty array as result.
Script below is took from Elasticsearch website and if you remove the 'Z' from the string and 'VV' from custom format it is returning empty array.
String datetime = 'custom y 1983 m 10 d 13 22:15:30 Z';
DateTimeFormatter dtf = DateTimeFormatter.ofPattern(
"'custom' 'y' yyyy 'm' MM 'd' dd HH:mm:ss VV");
ZonedDateTime zdt = ZonedDateTime.parse(datetime, dtf);
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.