exceptionfactory commented on a change in pull request #4781:
URL: https://github.com/apache/nifi/pull/4781#discussion_r564218598
##########
File path:
nifi-commons/nifi-record/src/main/java/org/apache/nifi/serialization/record/util/DataTypeUtils.java
##########
@@ -1085,6 +1087,28 @@ private static Object toEnum(Object value, EnumDataType
dataType, String fieldNa
throw new IllegalTypeConversionException("Cannot convert value [" +
value + "] of type " + value.getClass() + " to Date for field " + fieldName);
}
+ /**
+ * Converts a java.sql.Date object with 00:00:00 in local time zone
(typically coming from a java.sql.ResultSet)
+ * to UTC normalized form (storing epoch corresponding to UTC 00:00:00 on
the given day).
+ *
+ * @param date java.sql.Date with local time zone 00:00:00
+ * @return java.sql.Date with UTC 00:00:00
+ */
+ public static Date convertDateToUTC(Date date) {
+ return new
Date(date.toLocalDate().atStartOfDay(ZoneId.of("UTC")).toInstant().toEpochMilli());
Review comment:
Reading the documentation, `ZoneOffset` extends `ZoneId` so would
`ZoneOffset.UTC` function the same as `ZoneId.of("UTC")`?
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]