本文整理汇总了Java中org.hsqldb.types.TimestampData类的典型用法代码示例。如果您正苦于以下问题:Java TimestampData类的具体用法?Java TimestampData怎么用?Java TimestampData使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TimestampData类属于org.hsqldb.types包,在下文中一共展示了TimestampData类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: readDate
import org.hsqldb.types.TimestampData; //导入依赖的package包/类
protected TimestampData readDate(Type type) throws IOException {
readField();
if (value == null) {
return null;
}
if (version18) {
java.sql.Date dateTime = java.sql.Date.valueOf((String) value);
long millis =
HsqlDateTime.convertMillisFromCalendar(tempCalDefault,
dateTime.getTime());
millis = HsqlDateTime.getNormalisedDate(millis);
return new TimestampData(millis / 1000);
}
return scanner.newDate((String) value);
}
示例2: newDate
import org.hsqldb.types.TimestampData; //导入依赖的package包/类
public TimestampData newDate(String s) {
intervalPosition = 0;
fractionPrecision = 0;
dateTimeType = null;
intervalString = s;
scanDateParts(2);
if (intervalPosition != s.length()) {
throw Error.error(ErrorCode.X_22007);
}
long seconds = HsqlDateTime.getDateSeconds(s);
return new TimestampData(seconds);
}
示例3: readTimestamp
import org.hsqldb.types.TimestampData; //导入依赖的package包/类
protected TimestampData readTimestamp(Type type) throws IOException {
readField();
if (value == null) {
return null;
}
if (version18) {
java.sql.Timestamp dateTime =
java.sql.Timestamp.valueOf((String) value);
long millis =
HsqlDateTime.convertMillisFromCalendar(tempCalDefault,
dateTime.getTime());
int nanos = dateTime.getNanos();
nanos = ((DateTimeType) type).normaliseFraction(nanos, type.scale);
return new TimestampData(millis / 1000, nanos, 0);
}
return scanner.newTimestamp((String) value);
}
示例4: readTimestamp
import org.hsqldb.types.TimestampData; //导入依赖的package包/类
protected TimestampData readTimestamp(Type type) {
readField();
if (value == null) {
return null;
}
if (version18) {
java.sql.Timestamp dateTime =
java.sql.Timestamp.valueOf((String) value);
long millis =
HsqlDateTime.convertMillisFromCalendar(tempCalDefault,
dateTime.getTime());
int nanos = dateTime.getNanos();
nanos = DateTimeType.normaliseFraction(nanos, type.scale);
return new TimestampData(millis / 1000, nanos, 0);
}
return scanner.newTimestamp((String) value);
}
示例5: writeTimestamp
import org.hsqldb.types.TimestampData; //导入依赖的package包/类
protected void writeTimestamp(TimestampData o, Type type) {
if (type.typeCode == Types.SQL_TIMESTAMP) {
long millis = o.getSeconds() * 1000L;
millis = HsqlDateTime.convertMillisToCalendar(tempCalDefault,
millis);
writeLong(millis);
writeInt(o.getNanos());
} else {
writeLong(o.getSeconds());
writeInt(o.getNanos());
writeInt(o.getZone());
}
}
示例6: writeTimestamp
import org.hsqldb.types.TimestampData; //导入依赖的package包/类
protected void writeTimestamp(TimestampData o, Type type) {
writeLong(o.getSeconds());
writeInt(o.getNanos());
if (type.typeCode == Types.SQL_TIMESTAMP_WITH_TIME_ZONE) {
writeInt(o.getZone());
}
}
示例7: readTimestamp
import org.hsqldb.types.TimestampData; //导入依赖的package包/类
protected TimestampData readTimestamp(Type type) {
if (type.typeCode == Types.SQL_TIMESTAMP) {
long millis = readLong();
int nanos = readInt();
millis = HsqlDateTime.convertMillisFromCalendar(tempCalDefault,
millis);
return new TimestampData(millis / 1000, nanos);
} else {
return new TimestampData(readLong(), readInt(), readInt());
}
}
示例8: getSystemTimestamp
import org.hsqldb.types.TimestampData; //导入依赖的package包/类
synchronized TimestampData getSystemTimestamp(boolean withZone) {
long millis = System.currentTimeMillis();
long seconds = millis / 1000;
int nanos = (int) (millis % 1000) * 1000000;
TimeZone zone = TimeZone.getDefault();
int offset = zone.getOffset(millis) / 1000;
if (!withZone) {
seconds += offset;
offset = 0;
}
return new TimestampData(seconds, nanos, offset);
}
示例9: readTimestamp
import org.hsqldb.types.TimestampData; //导入依赖的package包/类
protected TimestampData readTimestamp(Type type) throws IOException {
if (type.typeCode == Types.SQL_TIMESTAMP) {
long millis = readLong();
int nanos = readInt();
millis = HsqlDateTime.convertMillisFromCalendar(tempCalDefault,
millis);
return new TimestampData(millis / 1000, nanos);
} else {
return new TimestampData(readLong(), readInt(), readInt());
}
}
示例10: readTimestamp
import org.hsqldb.types.TimestampData; //导入依赖的package包/类
protected TimestampData readTimestamp(Type type) throws IOException {
if (type.typeCode == Types.SQL_TIMESTAMP) {
return new TimestampData(readLong(), readInt());
} else {
return new TimestampData(readLong(), readInt(), readInt());
}
}
示例11: setDate
import org.hsqldb.types.TimestampData; //导入依赖的package包/类
/**
* <!-- start generic documentation -->
* Sets the designated parameter to the given <code>java.sql.Date</code> value,
* using the given <code>Calendar</code> object. The driver uses
* the <code>Calendar</code> object to construct an SQL <code>DATE</code> value,
* which the driver then sends to the database. With
* a <code>Calendar</code> object, the driver can calculate the date
* taking into account a custom timezone. If no
* <code>Calendar</code> object is specified, the driver uses the default
* timezone, which is that of the virtual machine running the application.
* <!-- end generic documentation -->
*
* @param parameterIndex the first parameter is 1, the second is 2, ...
* @param x the parameter value
* @param cal the <code>Calendar</code> object the driver will use
* to construct the date
* @exception SQLException if a database access error occurs or
* this method is called on a closed <code>PreparedStatement</code>
* @since JDK 1.2 (JDK 1.1.x developers: read the overview for
* JDBCParameterMetaData)
*/
public synchronized void setDate(int parameterIndex, Date x,
Calendar cal) throws SQLException {
checkSetParameterIndex(parameterIndex, false);
int i = parameterIndex - 1;
if (x == null) {
parameterValues[i] = null;
return;
}
Type outType = parameterTypes[i];
long millis = HsqlDateTime.convertToNormalisedDate(x.getTime(), cal);
int zoneOffset = HsqlDateTime.getZoneMillis(cal, millis);
switch (outType.typeCode) {
case Types.SQL_DATE :
case Types.SQL_TIMESTAMP :
case Types.SQL_TIMESTAMP_WITH_TIME_ZONE :
break;
default :
throw Util.sqlException(ErrorCode.X_42561);
}
parameterValues[i] = new TimestampData((millis + zoneOffset) / 1000);
}
示例12: toDate
import org.hsqldb.types.TimestampData; //导入依赖的package包/类
public static TimestampData toDate(String string, String pattern,
SimpleDateFormat format) {
Date date;
String javaPattern = HsqlDateTime.toJavaDatePattern(pattern);
int matchIndex = javaPattern.indexOf("*IY");
if (matchIndex >= 0) {
throw Error.error(ErrorCode.X_22511);
}
matchIndex = javaPattern.indexOf("*WW");
if (matchIndex >= 0) {
throw Error.error(ErrorCode.X_22511);
}
matchIndex = javaPattern.indexOf("*W");
if (matchIndex >= 0) {
throw Error.error(ErrorCode.X_22511);
}
try {
format.applyPattern(javaPattern);
date = format.parse(string);
} catch (Exception e) {
throw Error.error(ErrorCode.X_22007, e.toString());
}
int nanos = ((int) (date.getTime() % 1000)) * 1000000;
return new TimestampData(date.getTime() / 1000, nanos, 0);
}
示例13: readDate
import org.hsqldb.types.TimestampData; //导入依赖的package包/类
protected TimestampData readDate(Type type) {
String s = readString();
if (s == null) {
return null;
}
s = s.trim();
if (s.length() == 0) {
return null;
}
return scanner.newDate(s);
}
示例14: writeDate
import org.hsqldb.types.TimestampData; //导入依赖的package包/类
protected void writeDate(TimestampData o, Type type) {
writeLong(o.getSeconds());
}
示例15: writeDate
import org.hsqldb.types.TimestampData; //导入依赖的package包/类
protected void writeDate(TimestampData o, Type type) {
writeString(type.convertToString(o));
}