Skip to content

Commit

Permalink
ARROW-3966: Using a helper method for building a UTC calendar with ro…
Browse files Browse the repository at this point in the history
…ot locale.
  • Loading branch information
Mike Pigott committed Feb 3, 2019
1 parent 2928513 commit cfb2ba6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Calendar;
import java.util.Locale;
import java.util.TimeZone;

import org.apache.arrow.memory.BaseAllocator;
import org.apache.arrow.memory.RootAllocator;
Expand Down Expand Up @@ -90,7 +88,7 @@ public static VectorSchemaRoot sqlToArrow(Connection connection, String query, B
Preconditions.checkNotNull(allocator, "Memory allocator object can not be null");

JdbcToArrowConfig config =
new JdbcToArrowConfig(allocator, Calendar.getInstance(TimeZone.getTimeZone("UTC"), Locale.ROOT), false);
new JdbcToArrowConfig(allocator, JdbcToArrowUtils.getUtcCalendar(), false);
return sqlToArrow(connection, query, config);
}

Expand Down Expand Up @@ -155,7 +153,7 @@ public static VectorSchemaRoot sqlToArrow(Connection connection, String query, J
public static VectorSchemaRoot sqlToArrow(ResultSet resultSet) throws SQLException, IOException {
Preconditions.checkNotNull(resultSet, "JDBC ResultSet object can not be null");

return sqlToArrow(resultSet, Calendar.getInstance(TimeZone.getTimeZone("UTC"), Locale.ROOT));
return sqlToArrow(resultSet, JdbcToArrowUtils.getUtcCalendar());
}

/**
Expand All @@ -172,7 +170,7 @@ public static VectorSchemaRoot sqlToArrow(ResultSet resultSet, BaseAllocator all
Preconditions.checkNotNull(allocator, "Memory Allocator object can not be null");

JdbcToArrowConfig config =
new JdbcToArrowConfig(allocator, Calendar.getInstance(TimeZone.getTimeZone("UTC"), Locale.ROOT), false);
new JdbcToArrowConfig(allocator, JdbcToArrowUtils.getUtcCalendar(), false);
return sqlToArrow(resultSet, config);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@
import java.util.Calendar;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.TimeZone;

import org.apache.arrow.memory.RootAllocator;
import org.apache.arrow.vector.BaseFixedWidthVector;
Expand Down Expand Up @@ -108,6 +110,13 @@ public static Schema jdbcToArrowSchema(ResultSetMetaData rsmd, Calendar calendar
return jdbcToArrowSchema(rsmd, new JdbcToArrowConfig(new RootAllocator(0), calendar, false));
}

/**
* Returns the instance of a {java.util.Calendar} with the UTC time zone and root locale.
*/
public static Calendar getUtcCalendar() {
return Calendar.getInstance(TimeZone.getTimeZone("UTC"), Locale.ROOT);
}

/**
* Create Arrow {@link Schema} object for the given JDBC {@link ResultSetMetaData}.
*
Expand Down

0 comments on commit cfb2ba6

Please sign in to comment.