Skip to content

Commit

Permalink
Merge pull request #241 from bobobod/master
Browse files Browse the repository at this point in the history
fix:class 'ResultSetUtil.java' parse datetime type error #240
  • Loading branch information
CorvusYe authored Oct 23, 2023
2 parents fbeb601 + d10eaa4 commit 5e75595
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions src/main/java/org/nebula/contrib/ngbatis/utils/ResultSetUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import static org.nebula.contrib.ngbatis.utils.ReflectUtil.isCurrentTypeOrParentType;
import static org.nebula.contrib.ngbatis.utils.ReflectUtil.schemaByEntityType;

import com.vesoft.nebula.DateTime;
import com.vesoft.nebula.ErrorCode;
import com.vesoft.nebula.client.graph.data.DateTimeWrapper;
import com.vesoft.nebula.client.graph.data.DateWrapper;
Expand Down Expand Up @@ -126,27 +127,28 @@ public static <T> T getValue(ValueWrapper valueWrapper, Class<T> resultType) {
}

private static Object transformDateTime(DateTimeWrapper dateTime) {
DateTime localDateTime = dateTime.getLocalDateTime();
try {
CALENDAR_CONSTRUCTOR.setAccessible(true);
GregorianCalendar calendar = CALENDAR_CONSTRUCTOR.newInstance(
dateTime.getYear(),
dateTime.getMonth() - 1,
dateTime.getDay(),
dateTime.getHour(),
dateTime.getMinute(),
dateTime.getSecond(),
Math.floorDiv(dateTime.getMicrosec(), 1000)
localDateTime.getYear(),
localDateTime.getMonth() - 1,
localDateTime.getDay(),
localDateTime.getHour(),
localDateTime.getMinute(),
localDateTime.getSec(),
Math.floorDiv(localDateTime.getMicrosec(), 1000)
);
CALENDAR_CONSTRUCTOR.setAccessible(false);
return calendar.getTime();
} catch (Exception e) {
return new GregorianCalendar(
dateTime.getYear(),
dateTime.getMonth() - 1,
dateTime.getDay(),
dateTime.getHour(),
dateTime.getMinute(),
dateTime.getSecond()
localDateTime.getYear(),
localDateTime.getMonth() - 1,
localDateTime.getDay(),
localDateTime.getHour(),
localDateTime.getMinute(),
localDateTime.getSec()
).getTime();
}
}
Expand Down

0 comments on commit 5e75595

Please sign in to comment.