I am using a Field Type Converter to convert string to datetime with date format (yyyy-MM-dd'T'HHss.SSS'Z' - 2021-08-18T08:20:24.136000Z). However, the same field has dates with format 2021-08-18T08:20:24.00Z, which it gives me error CONVERTER_00 - Failed to convert field '/createdate' of type 'STRING' with value '2021-08-19T14:01:32Z' to type 'DATETIME'
Any recommendations on how to handle two different date formats for the same field?
Page 1 / 1
Since Java 8, you can use optional formatter options to parse and output dates. Use the following format instead of the one you show:
So, under he Conversions tab in the Field Type Converter, I would create 2 “section” to convert /createdate. One section would have date format yyyy-MM-dd'T'HHss.SSS'Z', and another that would have yyyy-MM-dd'T'HHss'Z'
No. Just use “Other Date Format” and the specify as format (single long line):
@mtaka Sorry. You are right. My suggestion would work if we used DatetTimeFormatter to make the datetime conversion, but currently we use SimpleDateFormat, which does not support optional formatting. Currently there is no direct method to accomplish this. A reasonable approach is stagging the conversion in two separate phases: normalization and conversion. You first normalize fields using processor “Field Replacer”. Then, having assured all fields have the same format, you convert them to datetime using “Field Type Converter” processor. This is one replacement expression that would do the trick: