提交 d7aa67f5 authored 作者: Noel Grandin's avatar Noel Grandin

comment some of the TIMESTAMP code better

上级 2a871b0b
......@@ -10,7 +10,7 @@ import org.h2.util.DateTimeUtils;
import org.h2.util.StringUtils;
/**
* How we expose "DATETIME WITH TIMEZONE" in our ResultSets.
* How we expose "TIMESTAMP WITH TIMEZONE" in our ResultSets.
*/
public class TimestampWithTimeZone implements Serializable, Cloneable {
......@@ -170,27 +170,29 @@ public class TimestampWithTimeZone implements Serializable, Cloneable {
@Override
public int hashCode() {
return 31 * super.hashCode() + timeZoneOffsetMins;
final int prime = 31;
int result = 1;
result = prime * result + (int) (dateValue ^ (dateValue >>> 32));
result = prime * result + (int) (timeNanos ^ (timeNanos >>> 32));
result = prime * result + timeZoneOffsetMins;
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
if (this == obj)
return true;
}
if (getClass() != obj.getClass()) {
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
}
TimestampWithTimeZone other = (TimestampWithTimeZone) obj;
if (dateValue != other.dateValue) {
if (dateValue != other.dateValue)
return false;
}
if (timeNanos != other.timeNanos) {
if (timeNanos != other.timeNanos)
return false;
}
if (timeZoneOffsetMins != other.timeZoneOffsetMins) {
if (timeZoneOffsetMins != other.timeZoneOffsetMins)
return false;
}
return true;
}
......
......@@ -30,8 +30,14 @@ public class ValueTime extends Value {
*/
static final int DISPLAY_SIZE = 8;
/**
* Nanoseconds since midnight
*/
private final long nanos;
/**
* @param nanos nanoseconds since midnight
*/
private ValueTime(long nanos) {
this.nanos = nanos;
}
......@@ -39,7 +45,7 @@ public class ValueTime extends Value {
/**
* Get or create a time value.
*
* @param nanos the nanoseconds
* @param nanos the nanoseconds since midnight
* @return the value
*/
public static ValueTime fromNanos(long nanos) {
......@@ -73,7 +79,6 @@ public class ValueTime extends Value {
* @param s the string to parse
* @return the time
*/
public static ValueTime parse(String s) {
try {
return fromNanos(DateTimeUtils.parseTimeNanos(s, 0, s.length(), false));
......@@ -83,6 +88,9 @@ public class ValueTime extends Value {
}
}
/**
* @return nanoseconds since midnight
*/
public long getNanos() {
return nanos;
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论