dan-s1 commented on code in PR #9196:
URL: https://github.com/apache/nifi/pull/9196#discussion_r1738786059


##########
nifi-extension-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestValidateRecord.java:
##########
@@ -593,6 +599,47 @@ public void testValidateMaps() throws IOException, 
InitializationException, Malf
         }
     }
 
+    @ParameterizedTest
+    @MethodSource("getLocales")
+    void testTimeZoneWithTimeStamp(Locale locale) throws Exception {
+        Locale originalLocale = Locale.getDefault();
+        Locale.setDefault(locale);
+        final String timestampWithTimeZonePattern = "dd/MM/yyyy HH:mm:ssZ";
+        final String schema = new 
String(Files.readAllBytes(Paths.get("src/test/resources/TestValidateRecord/timestampWithTimeZone.avsc")),
 "UTF-8");
+        final CSVReader csvReader = new CSVReader();
+        runner.addControllerService("reader", csvReader);
+        runner.setProperty(csvReader, 
SchemaAccessUtils.SCHEMA_ACCESS_STRATEGY, 
SchemaAccessUtils.SCHEMA_TEXT_PROPERTY);
+        runner.setProperty(csvReader, SchemaAccessUtils.SCHEMA_TEXT, schema);
+        runner.setProperty(csvReader, CSVUtils.FIRST_LINE_IS_HEADER, "true");
+        runner.setProperty(csvReader, CSVUtils.VALUE_SEPARATOR, "◆");
+        runner.setProperty(csvReader, DateTimeUtils.TIMESTAMP_FORMAT, 
timestampWithTimeZonePattern);
+        runner.enableControllerService(csvReader);
+
+        final CSVRecordSetWriter csvWriter = new CSVRecordSetWriter();
+        runner.addControllerService("writer", csvWriter);
+        runner.setProperty(csvWriter, "Schema Write Strategy", 
"full-schema-attribute");
+        runner.setProperty(csvWriter, DateTimeUtils.TIMESTAMP_FORMAT, 
timestampWithTimeZonePattern);
+        runner.enableControllerService(csvWriter);
+
+        runner.setProperty(ValidateRecord.RECORD_READER, "reader");
+        runner.setProperty(ValidateRecord.RECORD_WRITER, "writer");
+        runner.setProperty(ValidateRecord.ALLOW_EXTRA_FIELDS, "false");
+        runner.setProperty(ValidateRecord.MAX_VALIDATION_DETAILS_LENGTH, 
"4000");
+        runner.setProperty(ValidateRecord.VALIDATION_DETAILS_ATTRIBUTE_NAME, 
"valDetails");
+        final String timestampWithTimezone = "24/09/2024 15:04:23+0630";
+        final String content = 
"apache_date◆apache_ip_source◆apache_method◆apache_path◆apache_query_string◆apache_response_code◆apache_referer◆apache_user_agent\n"
 +
+                timestampWithTimezone + 
"◆10.4.3.20◆GET◆/path◆?test=toto◆200◆-◆";
+
+        runner.enqueue(content);
+        runner.run();
+
+        runner.assertTransferCount(ValidateRecord.REL_VALID, 1);
+        final MockFlowFile validFlowFile = 
runner.getFlowFilesForRelationship(ValidateRecord.REL_VALID).getFirst();
+        //Validate timezone is taken into account
+        
assertFalse(validFlowFile.getContent().contains(timestampWithTimezone));

Review Comment:
   BTW I do not have it working as I thought I did. Actually the time remains 
the same. This though does not address the first concern mentioned in the 
ticket 
   
   > When reading, the Z is accepted in the format but doesn't seem to be taken 
into account. Indeed, if we have a timestamp with +0200 (plus 2 hours), on 
output we have the timestamp on the NiFi timezone but without the time offset. 
For example, with 15h in +0200 I'd have 15h in +0000 instead of 13h in +0000.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to