ngbatis icon indicating copy to clipboard operation
ngbatis copied to clipboard

class 'ResultSetUtil.java' parse datetime type error

Open bobobod opened this issue 10 months ago • 4 comments

Time transfer error. The internal time of the datetimeWrapper is UTC time. If the time zone is East Eighth Zone, it will be eight hours less

private static Object transformDateTime(DateTimeWrapper dateTime) {
      // change here, maybe use localdateTime instead ? 
      DateTime localDateTime = dateTime.getLocalDateTime();
    try {
      CALENDAR_CONSTRUCTOR.setAccessible(true);
      GregorianCalendar calendar = CALENDAR_CONSTRUCTOR.newInstance(
        localDateTime .getYear(),
        localDateTime .getMonth() - 1,
        localDateTime .getDay(),
        localDateTime .getHour(),
        localDateTime .getMinute(),
        localDateTime .getSecond(),
        Math.floorDiv(localDateTime .getMicrosec(), 1000)
      );
      CALENDAR_CONSTRUCTOR.setAccessible(false);
      return calendar.getTime();
    } catch (Exception e) {
      return new GregorianCalendar(
        localDateTime .getYear(),
        localDateTime .getMonth() - 1,
        localDateTime .getDay(),
        localDateTime .getHour(),
        localDateTime .getMinute(),
        localDateTime .getSecond()
        ).getTime();
    }
  }

bobobod avatar Oct 07 '23 09:10 bobobod