提交 871aa89f authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov

Replace getTimeZoneName() with getTimeZone()

上级 3c39f6dd
......@@ -331,7 +331,7 @@ public class DateTimeUtils {
cal.setTime(value.getTime());
} else if (value instanceof ValueTimestampTimeZone) {
ValueTimestampTimeZone v = (ValueTimestampTimeZone) value;
cal = createGregorianCalendar(TimeZone.getTimeZone(v.getTimeZoneName()));
cal = createGregorianCalendar(v.getTimeZone());
cal.setTimeInMillis(DateTimeUtils.convertDateValueToMillis(DateTimeUtils.UTC, v.getDateValue())
+ v.getTimeNanos() / 1000000L
- v.getTimeZoneOffsetMins() * 60000);
......
......@@ -9,6 +9,7 @@ import java.math.BigDecimal;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.util.SimpleTimeZone;
import java.util.TimeZone;
import org.h2.api.ErrorCode;
import org.h2.api.TimestampWithTimeZone;
......@@ -202,27 +203,16 @@ public class ValueTimestampTimeZone extends Value {
}
/**
* Returns name of the timezone such as UTC or GMT+1:00.
* Returns compatible offset-based time zone with no DST schedule.
*
* @return name of the timezone
* @return compatible offset-based time zone
*/
public String getTimeZoneName() {
public TimeZone getTimeZone() {
int offset = timeZoneOffsetMins;
if (offset == 0)
return "UTC";
StringBuilder builder = new StringBuilder("GMT");
if (offset > 0) {
builder.append('+');
} else {
builder.append('-');
offset = -offset;
}
builder.append(offset / 60).append(':');
offset %= 60;
if (offset < 10)
builder.append('0');
builder.append(offset);
return builder.toString();
if (offset == 0) {
return DateTimeUtils.UTC;
}
return new SimpleTimeZone(offset * 60000, Integer.toString(offset));
}
@Override
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论