deniskuzZ commented on code in PR #5241:
URL: https://github.com/apache/hive/pull/5241#discussion_r1598995099
##########
ql/src/java/org/apache/hadoop/hive/ql/io/parquet/timestamp/NanoTimeUtils.java:
##########
@@ -102,10 +106,22 @@ public static Timestamp getTimestamp(NanoTime nt, ZoneId
targetZone, boolean leg
JulianDate jDateTime;
jDateTime = JulianDate.of((double) julianDay);
+ LocalDateTime localDateTime;
+ try {
+ localDateTime = jDateTime.toLocalDateTime();
Review Comment:
@simhadri-g , how about this
````
JulianDate jDateTime = JulianDate.of((double) julianDay);
LocalDateTime localDateTime;
int leapYearAdjustment = 0;
try {
localDateTime = jDateTime.toLocalDateTime();
} catch (DateTimeException e) {
if (e.getMessage().contains(ErrorMsg.NOT_LEAP_YEAR.getMsg()) &&
legacyConversion) {
localDateTime =
jDateTime.add(++leapYearAdjustment).toLocalDateTime();
} else {
throw e;
}
}
Calendar calendar = getGMTCalendar();
calendar.set(Calendar.YEAR, localDateTime.getYear());
calendar.set(Calendar.MONTH, localDateTime.getMonthValue() - 1); //java
calendar index starting at 1.
calendar.set(Calendar.DAY_OF_MONTH, localDateTime.getDayOfMonth());
int hour = (int) (remainder / (NANOS_PER_HOUR));
remainder = remainder % (NANOS_PER_HOUR);
int minutes = (int) (remainder / (NANOS_PER_MINUTE));
remainder = remainder % (NANOS_PER_MINUTE);
int seconds = (int) (remainder / (NANOS_PER_SECOND));
long nanos = remainder % NANOS_PER_SECOND;
calendar.set(Calendar.HOUR_OF_DAY, hour);
calendar.set(Calendar.MINUTE, minutes);
calendar.set(Calendar.SECOND, seconds);
Timestamp ts = Timestamp.ofEpochMilli(calendar.getTimeInMillis(), (int)
nanos);
ts = TimestampTZUtil.convertTimestampToZone(ts, ZoneOffset.UTC,
targetZone, legacyConversion)
.minusDays(leapYearAdjustment);
````
Timestamp
````
public Timestamp minusDays(long days) {
localDateTime = localDateTime.minusDays(days);
return this;
}
````
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]