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/07/17 00:49:31 UTC

[GitHub] [nifi] exceptionfactory commented on a change in pull request #5014: NIFI-8442 Convert Timestamp, Date and Time to String

exceptionfactory commented on a change in pull request #5014:
URL: https://github.com/apache/nifi/pull/5014#discussion_r671582027



##########
File path: nifi-nar-bundles/nifi-gcp-bundle/nifi-gcp-processors/src/main/java/org/apache/nifi/processors/gcp/bigquery/PutBigQueryStreaming.java
##########
@@ -191,6 +192,18 @@ public void onTrigger(ProcessContext context, ProcessSession session) throws Pro
                     lmapr.add(convertMapRecord(((MapRecord) mapr).toMap()));
                 }
                 result.put(key, lmapr);
+            } else if (obj instanceof Timestamp) {
+                SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+                format.setTimeZone(TimeZone.getTimeZone("UTC"));
+                result.put(key, format.format(((Timestamp) obj).getTime()));
+            } else if (obj instanceof Time) {
+                SimpleDateFormat format = new SimpleDateFormat("HH:mm:ss");
+                format.setTimeZone(TimeZone.getTimeZone("UTC"));
+                result.put(key, format.format(((Time) obj).getTime()));
+            } else if (obj instanceof Date) {
+                SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
+                format.setTimeZone(TimeZone.getTimeZone("UTC"));

Review comment:
       Setting the Time Zone to `UTC` can lead to unexpected results based on the system default time zone.




-- 
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