本文整理汇总了Java中org.hsqldb.HsqlDateTime.getDateString方法的典型用法代码示例。如果您正苦于以下问题:Java HsqlDateTime.getDateString方法的具体用法?Java HsqlDateTime.getDateString怎么用?Java HsqlDateTime.getDateString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.hsqldb.HsqlDateTime
的用法示例。
在下文中一共展示了HsqlDateTime.getDateString方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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");
}
}
示例2: 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");
}
}
示例3: setDate
import org.hsqldb.HsqlDateTime; //导入方法依赖的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
* 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. <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 date
* @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 setDate(int parameterIndex, java.sql.Date x,
Calendar cal) throws SQLException {
String s;
try {
s = HsqlDateTime.getDateString(x, cal);
} catch (Exception e) {
throw jdbcUtil.sqlException(Trace.INVALID_ESCAPE, e.getMessage());
}
setParameter(parameterIndex, s);
}
示例4: setDate
import org.hsqldb.HsqlDateTime; //导入方法依赖的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
* 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. <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 date
* @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 setDate(int parameterIndex, Date x,
Calendar cal) throws SQLException {
String s;
try {
s = HsqlDateTime.getDateString(x, cal);
} catch (Exception e) {
throw Util.sqlException(Trace.INVALID_ESCAPE, e.toString());
}
setParameter(parameterIndex, s);
}