本文整理汇总了Java中org.hsqldb.HsqlDateTime.getTimestampString方法的典型用法代码示例。如果您正苦于以下问题:Java HsqlDateTime.getTimestampString方法的具体用法?Java HsqlDateTime.getTimestampString怎么用?Java HsqlDateTime.getTimestampString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.hsqldb.HsqlDateTime
的用法示例。
在下文中一共展示了HsqlDateTime.getTimestampString方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getMessage
import org.hsqldb.HsqlDateTime; //导入方法依赖的package包/类
/**
* Subclass-specific override. <p>
*
* @return representation of <tt>lockFile</tt>, <tt>inMethod</tt>,
* <tt>read</tt> and <tt>heartbeat</tt>, as a <tt>String</tt>
* object
*/
public String getMessage() { // override
return super.getMessage() + " read: "
+ HsqlDateTime.getTimestampString(this.read)
+ " heartbeat - read: " + (this.heartbeat - this.read)
+ " ms.";
}
示例2: convertToDefaultType
import org.hsqldb.HsqlDateTime; //导入方法依赖的package包/类
/**
* Relaxes SQL parameter type enforcement, allowing long strings.
*/
public Object convertToDefaultType(SessionInterface session, Object a) {
if (a == null) {
return a;
}
String s;
if (a instanceof Boolean) {
s = a.toString();
} else if (a instanceof BigDecimal) {
s = JavaSystem.toString((BigDecimal) a);
} else if (a instanceof Number) {
s = a.toString(); // use shortcut
} else if (a instanceof String) {
s = (String) a;
} else if (a instanceof java.sql.Date) {
s = a.toString();
} else if (a instanceof java.sql.Time) {
s = a.toString();
} else if (a instanceof java.sql.Timestamp) {
s = a.toString();
} else if (a instanceof java.util.Date) {
s = HsqlDateTime.getTimestampString(
((java.util.Date) a).getTime());
} else {
throw Error.error(ErrorCode.X_42561);
}
return s;
// return convertToType(session, a, Type.SQL_VARCHAR);
}
示例3: convertToDefaultType
import org.hsqldb.HsqlDateTime; //导入方法依赖的package包/类
/**
* Relaxes SQL parameter type enforcement, allowing long strings.
*/
public Object convertToDefaultType(SessionInterface session, Object a) {
if (a == null) {
return a;
}
String s;
if (a instanceof Boolean) {
s = a.toString();
} else if (a instanceof BigDecimal) {
s = JavaSystem.toString((BigDecimal) a);
} else if (a instanceof Number) {
s = a.toString(); // use shortcut
} else if (a instanceof String) {
s = (String) a;
} else if (a instanceof java.sql.Date) {
s = ((java.sql.Date) a).toString();
} else if (a instanceof java.sql.Time) {
s = ((java.sql.Time) a).toString();
} else if (a instanceof java.sql.Timestamp) {
s = ((java.sql.Timestamp) a).toString();
} else if (a instanceof java.util.Date) {
s = HsqlDateTime.getTimestampString(((java.util.Date) a).getTime());
} else {
throw Error.error(ErrorCode.X_42561);
}
return s;
// return convertToType(session, a, Type.SQL_VARCHAR);
}
示例4: convertToString
import org.hsqldb.HsqlDateTime; //导入方法依赖的package包/类
public String convertToString(Object a) {
boolean zone = false;
String s;
StringBuffer sb;
if (a == null) {
return null;
}
switch (typeCode) {
case Types.SQL_DATE :
return HsqlDateTime.getDateString(
((TimestampData) a).getSeconds());
case Types.SQL_TIME_WITH_TIME_ZONE :
case Types.SQL_TIME : {
TimeData t = (TimeData) a;
int seconds = normaliseTime(t.getSeconds() + t.getZone());
s = intervalSecondToString(seconds, t.getNanos(), false);
if (!withTimeZone) {
return s;
}
sb = new StringBuffer(s);
s = Type.SQL_INTERVAL_HOUR_TO_MINUTE.intervalSecondToString(
((TimeData) a).getZone(), 0, true);
sb.append(s);
return sb.toString();
}
case Types.SQL_TIMESTAMP_WITH_TIME_ZONE :
case Types.SQL_TIMESTAMP : {
TimestampData ts = (TimestampData) a;
sb = new StringBuffer();
HsqlDateTime.getTimestampString(sb,
ts.getSeconds()
+ ts.getZone(), ts.getNanos(),
scale);
if (!withTimeZone) {
return sb.toString();
}
s = Type.SQL_INTERVAL_HOUR_TO_MINUTE.intervalSecondToString(
((TimestampData) a).getZone(), 0, true);
sb.append(s);
return sb.toString();
}
default :
throw Error.runtimeError(ErrorCode.U_S0500, "DateTimeType");
}
}
示例5: convertToString
import org.hsqldb.HsqlDateTime; //导入方法依赖的package包/类
@Override
public String convertToString(Object a) {
boolean zone = false;
String s;
StringBuffer sb;
if (a == null) {
return null;
}
switch (typeCode) {
case Types.SQL_DATE :
return HsqlDateTime.getDateString(
((TimestampData) a).getSeconds());
case Types.SQL_TIME_WITH_TIME_ZONE :
zone = true;
// fall through
case Types.SQL_TIME : {
TimeData t = (TimeData) a;
int seconds = normaliseTime(t.getSeconds() + t.getZone());
s = intervalSecondToString(seconds, t.getNanos(), false);
if (!zone) {
return s;
}
sb = new StringBuffer(s);
s = Type.SQL_INTERVAL_HOUR_TO_MINUTE.intervalSecondToString(
((TimeData) a).getZone(), 0, true);
sb.append(s);
return sb.toString();
}
case Types.SQL_TIMESTAMP_WITH_TIME_ZONE :
zone = true;
// fall through
case Types.SQL_TIMESTAMP : {
TimestampData ts = (TimestampData) a;
sb = new StringBuffer();
HsqlDateTime.getTimestampString(sb,
ts.getSeconds()
+ ts.getZone(), ts.getNanos(),
scale);
if (!zone) {
return sb.toString();
}
s = Type.SQL_INTERVAL_HOUR_TO_MINUTE.intervalSecondToString(
((TimestampData) a).getZone(), 0, true);
sb.append(s);
return sb.toString();
}
default :
throw Error.runtimeError(ErrorCode.U_S0500, "DateTimeType");
}
}
示例6: setTimestamp
import org.hsqldb.HsqlDateTime; //导入方法依赖的package包/类
/**
* <!-- start generic documentation -->
* Sets the designated parameter to the given <code>java.sql.Timestamp</code>
* value, using the given <code>Calendar</code> object. The driver uses
* the <code>Calendar</code> object to construct an SQL <code>TIMESTAMP</code>
* value, which the driver then sends to the database. With a
* <code>Calendar</code> object, the driver can calculate the timestamp
* 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. <p>
* <!-- 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 timestamp
* @exception SQLException if a database access error occurs
* @since JDK 1.2 (JDK 1.1.x developers: read the new overview for
* jdbcPreparedStatement)
*/
// [email protected] 20020414 - patch 517028 by [email protected] - method defined
// changes by fredt - moved conversion to HsqlDateTime
public void setTimestamp(int parameterIndex, java.sql.Timestamp x,
Calendar cal) throws SQLException {
checkSetParameterIndex(parameterIndex);
String s;
try {
s = HsqlDateTime.getTimestampString(x, cal);
} catch (Exception e) {
throw jdbcUtil.sqlException(Trace.INVALID_ESCAPE, e.getMessage());
}
setParameter(parameterIndex, s);
}