Scripted fields date parse

i extracted tweets from twitter and then i imported the json files into elasticsearch using kibana. I have this field called created_at that has this format Wed Jan 30 18:12:02 +0000 2019 and i have not date field. i tried using scripted fields to parse it into a date by using :

new SimpleDateFormat('MMM D HH:mm:ss ZZ YYYY').parse(doc['created_at'].value.substring(4)).getTime()

and i get a result of December 30th 2018, 18:12:02.000
its giving December instead of January and 2018 instead of 2019

Hi there, the problem is your use of YYYY. This is the week-year, when you want the calendar year. Use yyyy and this will return the correct date. Reference: https://stackoverflow.com/questions/14755742/java-date-year-calculation-is-off-by-year-for-two-days.

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