From d10eaa428c5be9f0b2df0c6b2e2d02c9cf6f6ef2 Mon Sep 17 00:00:00 2001 From: jerry Date: Sat, 7 Oct 2023 19:54:05 +0800 Subject: [PATCH] fix:class 'ResultSetUtil.java' parse datetime type error #240 --- .../contrib/ngbatis/utils/ResultSetUtil.java | 28 ++++++++++--------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/src/main/java/org/nebula/contrib/ngbatis/utils/ResultSetUtil.java b/src/main/java/org/nebula/contrib/ngbatis/utils/ResultSetUtil.java index 715211ae..5d91c9ed 100644 --- a/src/main/java/org/nebula/contrib/ngbatis/utils/ResultSetUtil.java +++ b/src/main/java/org/nebula/contrib/ngbatis/utils/ResultSetUtil.java @@ -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; @@ -126,27 +127,28 @@ public static T getValue(ValueWrapper valueWrapper, Class 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(); } }