Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix:class 'ResultSetUtil.java' parse datetime type error #240 #241

Merged
merged 1 commit into from
Oct 23, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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();
Copy link
Contributor

@Nicole00 Nicole00 Oct 11, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we give some description about Why convert the datetime to localDateTime?
If i am using other zone but not utc8, is there any problems with the results?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we give some description about Why convert the datetime to localDateTime? If i am using other zone but not utc8, is there any problems with the results?

It seems like this.

#240

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You'd better test it locally.when the zone is GMT+8, this method of converting time will ultimately result in 8 hours less than expected.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My nebula-storaged has been unable to start recently and lacks a cross time zone testing environment, so it has been unable to verify. T^T

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image
This looks like the data returned after calling the service is correct, but after conversion, an error occurred

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's the time zone of the machine where the nebula service is located?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it‘s deployed on a virtual machine, the time zone is correct.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see the point, use LocalDateTime can get the correct time info according to the local zone.

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
Loading