lriggs commented on code in PR #1541:
URL: https://github.com/apache/arrow-java/pull/1541#discussion_r4774169141


##########
flight/flight-sql-jdbc-core/src/test/java/org/apache/arrow/driver/jdbc/accessor/impl/calendar/ArrowFlightJdbcTimeVectorAccessorTest.java:
##########
@@ -265,6 +269,81 @@ public void testValidateGetStringTimeZoneConsistency(
         });
   }
 
+  @Test

Review Comment:
   Consider a test like this to fully cover the calendar conversion in getTime.
   
   ```
   @Test
   public void testGetTimeWithCalendarInNonUtcDefaultZone() throws Exception {
     // 12:34:56.789 = 45_296_789 ms of the day
     final int millisOfDay = (int) 
(LocalTime.parse("12:34:56.789").toNanoOfDay() / 1_000_000);
     try (TimeMilliVector milliVector =
         new TimeMilliVector("", 
rootAllocatorTestExtension.getRootAllocator())) {
       milliVector.setSafe(0, millisOfDay);
       milliVector.setValueCount(1);
       this.vector = milliVector;
   
       final TimeZone defaultTz = TimeZone.getDefault();
       try {
         TimeZone.setDefault(TimeZone.getTimeZone("Europe/Berlin")); // UTC+1 
on 1970-01-01
         ArrowFlightJdbcTimeVectorAccessor accessor = 
accessorSupplier.supply(vector, () -> 0);
         Calendar vancouver = 
Calendar.getInstance(TimeZone.getTimeZone(AMERICA_VANCOUVER)); // UTC-8
   
         // JDBC: the calendar's zone gives the wall-clock time its instant.
         // 12:34:56.789 in Vancouver = 20:34:56.789 UTC = 74_096_789 epoch ms.
         // The old code also added the default zone's offset and gave 
77_696_789 (21:34:56.789 UTC).
         assertThat(accessor.getTime(vancouver).getTime(), is(74_096_789L));
         assertThat(accessor.getTimestamp(vancouver).getTime(), 
is(74_096_789L));
   
         // With no calendar, the default zone is used: 12:34:56.789 in Berlin 
= 11:34:56.789 UTC.
         // The old code returned the raw 45_296_789, which prints as 
13:34:56.789 in Berlin.
         assertThat(accessor.getTime(null).getTime(), is(41_696_789L));
         assertThat(accessor.getTime(null).toString(), is("12:34:56.789"));
       } finally {
         TimeZone.setDefault(defaultTz);
       }
     }
   }
   ```



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