本文整理汇总了Java中org.hsqldb.types.DTIType.timezoneSecondsLimit方法的典型用法代码示例。如果您正苦于以下问题:Java DTIType.timezoneSecondsLimit方法的具体用法?Java DTIType.timezoneSecondsLimit怎么用?Java DTIType.timezoneSecondsLimit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.hsqldb.types.DTIType
的用法示例。
在下文中一共展示了DTIType.timezoneSecondsLimit方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: newTimestamp
import org.hsqldb.types.DTIType; //导入方法依赖的package包/类
/**
* @todo 1.9.0 - review the following
* - misses nano fractions
* - misses displacement
* - doesn't allow single digit components
*/
public TimestampData newTimestamp(String s) {
long zoneSeconds = 0;
long seconds;
int fraction = 0;
int endIndex = s.length();
boolean negate;
boolean hasZone = false;
intervalPosition = 0;
fractionPrecision = 0;
dateTimeType = null;
intervalString = s;
scanDateParts(5);
try {
seconds = HsqlDateTime.getTimestampSeconds(s.substring(0,
intervalPosition));
} catch (Throwable e) {
throw Error.error(ErrorCode.X_22007);
}
int position;
fraction = scanIntervalFraction(DTIType.maxFractionPrecision);
position = intervalPosition;
negate = scanIntervalSign();
if (negate || position != intervalPosition) {
zoneSeconds = scanIntervalValue(Type.SQL_INTERVAL_HOUR_TO_MINUTE);
hasZone = true;
if (negate) {
zoneSeconds = -zoneSeconds;
}
}
if (zoneSeconds >= DTIType.yearToSecondFactors[2]
|| zoneSeconds > DTIType.timezoneSecondsLimit
|| -zoneSeconds > DTIType.timezoneSecondsLimit) {
throw Error.error(ErrorCode.X_22009);
}
if (intervalPosition != endIndex) {
throw Error.error(ErrorCode.X_22007);
}
int type = hasZone ? Types.SQL_TIMESTAMP_WITH_TIME_ZONE
: Types.SQL_TIMESTAMP;
dateTimeType = DateTimeType.getDateTimeType(type, fractionPrecision);
if (hasZone) {
seconds -= zoneSeconds;
}
return new TimestampData(seconds, fraction, (int) zoneSeconds);
}
示例2: newTime
import org.hsqldb.types.DTIType; //导入方法依赖的package包/类
public TimeData newTime(String s) {
intervalPosition = 0;
fractionPrecision = 0;
dateTimeType = null;
intervalString = s;
long seconds = scanIntervalValue(Type.SQL_INTERVAL_HOUR_TO_SECOND);
int fraction = scanIntervalFraction(DTIType.maxFractionPrecision);
long zoneSeconds = 0;
int position = intervalPosition;
boolean hasZone = false;
boolean negate = scanIntervalSign();
if (position != intervalPosition) {
zoneSeconds = scanIntervalValue(Type.SQL_INTERVAL_HOUR_TO_MINUTE);
hasZone = true;
}
if (intervalPosition != s.length()) {
throw Error.error(ErrorCode.X_22009);
}
if (seconds >= DTIType.yearToSecondFactors[2]) {
throw Error.error(ErrorCode.X_22008);
}
if (zoneSeconds > DTIType.timezoneSecondsLimit) {
throw Error.error(ErrorCode.X_22009);
}
if (negate) {
zoneSeconds = -zoneSeconds;
}
int type = hasZone ? Types.SQL_TIME_WITH_TIME_ZONE
: Types.SQL_TIME;
dateTimeType = DateTimeType.getDateTimeType(type, fractionPrecision);
if (hasZone) {
seconds -= zoneSeconds;
}
return new TimeData((int) seconds, fraction, (int) zoneSeconds);
}