You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by GitBox <gi...@apache.org> on 2021/06/29 21:00:23 UTC

[GitHub] [nifi] granthenke commented on a change in pull request #5194: NIFI-8748 Corrected PutKudu String to java.sql.Date parsing

granthenke commented on a change in pull request #5194:
URL: https://github.com/apache/nifi/pull/5194#discussion_r660959323



##########
File path: nifi-nar-bundles/nifi-kudu-bundle/nifi-kudu-processors/src/main/java/org/apache/nifi/processors/kudu/AbstractKuduProcessor.java
##########
@@ -412,6 +415,26 @@ protected void buildPartialRow(Schema schema, PartialRow row, Record record, Lis
         }
     }
 
+    /**
+     * Get java.sql.Date from Record Field Value with optional parsing when input value is a String
+     *
+     * @param value Record Field Value
+     * @param recordFieldName Record Field Name
+     * @return Date object or null when value is null
+     */
+    private Date getDate(final Object value, final String recordFieldName) {
+        return DataTypeUtils.toDate(value, () -> getDateFormat(), recordFieldName);
+    }
+
+    /**
+     * Get Date Format using Date Record Field default pattern and system time zone to avoid unnecessary conversion
+     *
+     * @return Date Format used to parsing date fields
+     */
+    private DateFormat getDateFormat() {
+        return new SimpleDateFormat(RecordFieldType.DATE.getDefaultFormat());

Review comment:
       Should this use `fieldType.getFormat()` similar to the handling for Timestamp/UNIXTIME_MICROS above?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org