Hive Date to Java SQL Date Conversion
To convert org.apache.hadoop.hive.common.type.Date to java.sql.Date, you can use the following code:
org.apache.hadoop.hive.common.type.Date hiveDate = ...; // org.apache.hadoop.hive.common.type.Date object
long millis = hiveDate.getDaysSinceEpoch() * 24 * 60 * 60 * 1000; // Convert days to milliseconds
java.sql.Date sqlDate = new java.sql.Date(millis); // Create java.sql.Date object using milliseconds
Make sure to import the necessary packages before using the code:
import org.apache.hadoop.hive.common.type.Date;
import java.sql.Date;
This will convert your org.apache.hadoop.hive.common.type.Date to java.sql.Date.
原文地址: https://www.cveoy.top/t/topic/jCnT 著作权归作者所有。请勿转载和采集!