lidavidm commented on code in PR #35139:
URL: https://github.com/apache/arrow/pull/35139#discussion_r1167344679


##########
java/flight/flight-sql-jdbc-core/src/test/java/org/apache/arrow/driver/jdbc/accessor/impl/text/ArrowFlightJdbcVarCharVectorAccessorTest.java:
##########
@@ -510,14 +510,23 @@ public void 
testShouldGetDateReturnValidDateWithCalendar() throws Exception {
     Text value = new Text("2021-07-02");
     when(getter.get(0)).thenReturn(value.copyBytes());
 
-    Calendar calendar = 
Calendar.getInstance(TimeZone.getTimeZone("America/Sao_Paulo"));
-    Date result = accessor.getDate(calendar);
+    {
+      Calendar calendar = 
Calendar.getInstance(TimeZone.getTimeZone("America/Sao_Paulo"));
+      Date result = accessor.getDate(calendar);
+      calendar.setTime(result);
 
-    calendar = Calendar.getInstance(TimeZone.getTimeZone("Etc/UTC"));
-    calendar.setTime(result);
+      collector.checkThat(dateTimeFormat.format(calendar.getTime()),
+          equalTo("2021-07-01T21:00:00.000Z"));

Review Comment:
   OK. So the assumption is that the underlying value is in UTC, and are 
converting to the destination time zone?
   
   Derby does something different, though:
   
   ```java
       SimpleDateFormat sdf = new 
SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSXXX");
       try (final Connection connection = 
DriverManager.getConnection("jdbc:derby:memory:foo;create=true")) {
         try (final Statement statement = connection.createStatement()) {
           statement.executeUpdate("CREATE TABLE foo (bar DATE)");
           statement.executeUpdate("INSERT INTO foo (bar) VALUES '2021-07-02'");
           try (final ResultSet rs = statement.executeQuery("SELECT * FROM 
foo")) {
             assertThat(rs.next()).isTrue();
             Calendar calendar = 
Calendar.getInstance(TimeZone.getTimeZone("America/Sao_Paulo"));
             final Date date = rs.getDate(1, calendar);
             System.out.println(date);
             calendar.setTime(date);
             System.out.println(sdf.format(calendar.getTime()));
           }
         }
       }
   ```
   
   Derby appears to just attach the timezone to the value, instead of adjusting 
it from an assumed source time zone. The output is:
   
   ```
   2021-07-02
   2021-07-02T12:00:00.000+09:00
   ```



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