<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>question Re: How to convert String Date &amp;quot;Wed Oct 13 15:58:58 IST 2021&amp;quot; to DATETIME datatype like &amp;quot;2021-10-13 15:58:58&amp;quot; in  JsonPathReader to save in MySql DB in Support Questions</title>
    <link>https://community.cloudera.com/t5/Support-Questions/How-to-convert-String-Date-quot-Wed-Oct-13-15-58-58-IST-2021/m-p/347194#M235095</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I ran into this issue before when dealing with ISO timeformat and it would not allow me to write to the DB. In this case you have to use an updateAttribute to convert this format to the format that DB can accept (yyyy-MM-dd HH:mm:ss), this worked for me:&lt;/P&gt;&lt;P&gt;${literal('Wed Oct 13 15:58:58 IST 2021'):replaceAll('(IST)\s',''):toDate('EEE MMM dd HH:mm:ss yyyy'):format('yyyy-MM-dd HH:mm:ss')}&lt;/P&gt;&lt;P&gt;Hope it would help.&lt;/P&gt;</description>
    <pubDate>Fri, 08 Jul 2022 19:51:32 GMT</pubDate>
    <dc:creator>SAMSAL</dc:creator>
    <dc:date>2022-07-08T19:51:32Z</dc:date>
    <item>
      <title>How to convert String Date "Wed Oct 13 15:58:58 IST 2021" to DATETIME datatype like "2021-10-13 15:58:58" in  JsonPathReader to save in MySql DB</title>
      <link>https://community.cloudera.com/t5/Support-Questions/How-to-convert-String-Date-quot-Wed-Oct-13-15-58-58-IST-2021/m-p/347160#M235084</link>
      <description>&lt;P&gt;I am getting&amp;nbsp;String Date "Wed Oct 13 15:58:58 IST 2021" in changeCaptureMySql processor flowfile content out claim which is getting read from mysql-bin.log file as source DB data. Destination DB column has datatype DATETIME. I am using the JsonPathReader and AvroSchemaRegistry to read the each column data to save in db but it is giving data incorrect date-time value error.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Q1. Is there any away I can convert String date time value to DATETIME to save it without error?&lt;/P&gt;&lt;P&gt;Q2. How to define the&amp;nbsp;DATETIME data type in&amp;nbsp;AvroSchemaRegistry ?.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried below data type in AvroSchemaRegistry but it won't work.&lt;/P&gt;&lt;P&gt;Please find the attached screenshot for reference.&lt;/P&gt;&lt;P&gt;{ "name": "TIMESTAMP" , "type": { "type":"long", "logicalType":"timestamp-millis"} }, { "name": "DATE" , "type": { "type":"int", "logicalType":"date"} }&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="incorrect_datetimeValueError.png" style="width: 999px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/34809i21E6E9044F7976BA/image-size/large?v=v2&amp;amp;px=999" role="button" title="incorrect_datetimeValueError.png" alt="incorrect_datetimeValueError.png" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot from 2022-07-08 20-15-03.png" style="width: 999px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/34810iE105B03E302249FC/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screenshot from 2022-07-08 20-15-03.png" alt="Screenshot from 2022-07-08 20-15-03.png" /&gt;&lt;/span&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 08 Jul 2022 15:23:21 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/How-to-convert-String-Date-quot-Wed-Oct-13-15-58-58-IST-2021/m-p/347160#M235084</guid>
      <dc:creator>AbhishekSingh</dc:creator>
      <dc:date>2022-07-08T15:23:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert String Date "Wed Oct 13 15:58:58 IST 2021" to DATETIME datatype like "2021-10-13 15:58:58" in  JsonPathReader to save in MySql DB</title>
      <link>https://community.cloudera.com/t5/Support-Questions/How-to-convert-String-Date-quot-Wed-Oct-13-15-58-58-IST-2021/m-p/347194#M235095</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I ran into this issue before when dealing with ISO timeformat and it would not allow me to write to the DB. In this case you have to use an updateAttribute to convert this format to the format that DB can accept (yyyy-MM-dd HH:mm:ss), this worked for me:&lt;/P&gt;&lt;P&gt;${literal('Wed Oct 13 15:58:58 IST 2021'):replaceAll('(IST)\s',''):toDate('EEE MMM dd HH:mm:ss yyyy'):format('yyyy-MM-dd HH:mm:ss')}&lt;/P&gt;&lt;P&gt;Hope it would help.&lt;/P&gt;</description>
      <pubDate>Fri, 08 Jul 2022 19:51:32 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/How-to-convert-String-Date-quot-Wed-Oct-13-15-58-58-IST-2021/m-p/347194#M235095</guid>
      <dc:creator>SAMSAL</dc:creator>
      <dc:date>2022-07-08T19:51:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert String Date "Wed Oct 13 15:58:58 IST 2021" to DATETIME datatype like "2021-10-13 15:58:58" in  JsonPathReader to save in MySql DB</title>
      <link>https://community.cloudera.com/t5/Support-Questions/How-to-convert-String-Date-quot-Wed-Oct-13-15-58-58-IST-2021/m-p/347334#M235129</link>
      <description>&lt;P&gt;I tried above conversion but I am getting below error.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;AvroSchema:&lt;/STRONG&gt;&amp;nbsp;{ "name": "enrolled_at", "type": { "type":"int", "logicalType":"date"} },&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;ErrorLog:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;org.apache.nifi.serialization.MalformedRecordException: Successfully parsed a JSON object from input but failed to convert into a Record object with the given schema&lt;BR /&gt;at org.apache.nifi.json.AbstractJsonRowRecordReader.nextRecord(AbstractJsonRowRecordReader.java:162)&lt;BR /&gt;at org.apache.nifi.serialization.RecordReader.nextRecord(RecordReader.java:50)&lt;BR /&gt;at jdk.internal.reflect.GeneratedMethodAccessor653.invoke(Unknown Source)&lt;/P&gt;&lt;P&gt;Caused by: com.jayway.jsonpath.InvalidPathException: Function with name: {literal does not exist.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 11 Jul 2022 17:18:17 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/How-to-convert-String-Date-quot-Wed-Oct-13-15-58-58-IST-2021/m-p/347334#M235129</guid>
      <dc:creator>AbhishekSingh</dc:creator>
      <dc:date>2022-07-11T17:18:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert String Date "Wed Oct 13 15:58:58 IST 2021" to DATETIME datatype like "2021-10-13 15:58:58" in  JsonPathReader to save in MySql DB</title>
      <link>https://community.cloudera.com/t5/Support-Questions/How-to-convert-String-Date-quot-Wed-Oct-13-15-58-58-IST-2021/m-p/347336#M235131</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Can you post the Expression Language you used? I'm seeing in the error message that its complaining about the "literal" function doesnt exist. Did you use it with the variable name that contains the original date value? If so then remove the literal function and just keep the variable since literal works with constants. So the expression should be something like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;${date_variable:replaceAll('(IST)\s',''):toDate('EEE MMM dd HH:mm:ss yyyy'):format('yyyy-MM-dd HH:mm:ss')}&lt;/P&gt;</description>
      <pubDate>Mon, 11 Jul 2022 17:32:39 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/How-to-convert-String-Date-quot-Wed-Oct-13-15-58-58-IST-2021/m-p/347336#M235131</guid>
      <dc:creator>SAMSAL</dc:creator>
      <dc:date>2022-07-11T17:32:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert String Date "Wed Oct 13 15:58:58 IST 2021" to DATETIME datatype like "2021-10-13 15:58:58" in  JsonPathReader to save in MySql DB</title>
      <link>https://community.cloudera.com/t5/Support-Questions/How-to-convert-String-Date-quot-Wed-Oct-13-15-58-58-IST-2021/m-p/347339#M235133</link>
      <description>&lt;P&gt;I tried again below expressions:&lt;/P&gt;&lt;P&gt;1.&amp;nbsp;$.{enrolled_at:replaceAll('(IST)\s',''):toDate('EEE MMM dd HH:mm:ss yyyy'):format('yyyy-MM-dd HH:mm:ss')} // &lt;STRONG&gt;got error&amp;nbsp;{enrolled_at:replaceAll does not exist.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;2.&amp;nbsp;${enrolled_at:replaceAll('(IST)\s',''):toDate('EEE MMM dd HH:mm:ss yyyy'):format('yyyy-MM-dd HH:mm:ss')} // expression validation failling&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot from 2022-07-11 23-30-21.png" style="width: 999px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/34827i3D664F54AC055952/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screenshot from 2022-07-11 23-30-21.png" alt="Screenshot from 2022-07-11 23-30-21.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 11 Jul 2022 18:06:05 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/How-to-convert-String-Date-quot-Wed-Oct-13-15-58-58-IST-2021/m-p/347339#M235133</guid>
      <dc:creator>AbhishekSingh</dc:creator>
      <dc:date>2022-07-11T18:06:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert String Date "Wed Oct 13 15:58:58 IST 2021" to DATETIME datatype like "2021-10-13 15:58:58" in  JsonPathReader to save in MySql DB</title>
      <link>https://community.cloudera.com/t5/Support-Questions/How-to-convert-String-Date-quot-Wed-Oct-13-15-58-58-IST-2021/m-p/347340#M235134</link>
      <description>&lt;P&gt;You cant use Expression Language when setting values in the JsonPathReader processor. You need to get the value first as is using the json path&amp;nbsp; and then use an updateAttribute processor on it using the expression above. In updateAttribute you can use the same variable name or different one.&lt;/P&gt;</description>
      <pubDate>Mon, 11 Jul 2022 18:21:38 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/How-to-convert-String-Date-quot-Wed-Oct-13-15-58-58-IST-2021/m-p/347340#M235134</guid>
      <dc:creator>SAMSAL</dc:creator>
      <dc:date>2022-07-11T18:21:38Z</dc:date>
    </item>
  </channel>
</rss>

