提交 8c616222 authored 作者: Thomas Mueller's avatar Thomas Mueller

The JDBC methods PreparedStatement.setTimestamp, setTime, and setDate with a…

The JDBC methods PreparedStatement.setTimestamp, setTime, and setDate with a calendar, and the methods ResultSet.getTimestamp, getTime, and getDate with a calendar converted the value in the wrong way, so that for some timestamps the converted value was wrong (where summertime starts, one hour per year).
上级 2e556139
...@@ -158,7 +158,7 @@ public class DateTimeUtils { ...@@ -158,7 +158,7 @@ public class DateTimeUtils {
(int) h, (int) m, (int) s, (int) millis); (int) h, (int) m, (int) s, (int) millis);
long ms = cal.getTimeInMillis(); long ms = cal.getTimeInMillis();
Timestamp x = new Timestamp(ms); Timestamp x = new Timestamp(ms);
x.setNanos((int) nanos); x.setNanos((int) (nanos + millis * 1000000));
return x; return x;
} }
...@@ -226,7 +226,7 @@ public class DateTimeUtils { ...@@ -226,7 +226,7 @@ public class DateTimeUtils {
to.set(Calendar.SECOND, from.get(Calendar.SECOND)); to.set(Calendar.SECOND, from.get(Calendar.SECOND));
to.set(Calendar.MILLISECOND, from.get(Calendar.MILLISECOND)); to.set(Calendar.MILLISECOND, from.get(Calendar.MILLISECOND));
} }
/** /**
* Convert the timestamp using the specified calendar. * Convert the timestamp using the specified calendar.
* *
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论