本文整理汇总了Java中org.hsqldb.HsqlDateTime类的典型用法代码示例。如果您正苦于以下问题:Java HsqlDateTime类的具体用法?Java HsqlDateTime怎么用?Java HsqlDateTime使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
HsqlDateTime类属于org.hsqldb包,在下文中一共展示了HsqlDateTime类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: logContext
import org.hsqldb.HsqlDateTime; //导入依赖的package包/类
public synchronized void logContext(int atLevel, String message) {
if (level < atLevel) {
return;
}
String info = HsqlDateTime.getSytemTimeString();
//#ifdef JAVA4
Throwable temp = new Throwable();
StackTraceElement[] elements = temp.getStackTrace();
if (elements.length > 1) {
info += " " + elements[1].getClassName() + "."
+ elements[1].getMethodName();
}
//#endif JAVA4
writer.println(info + " " + message);
}
示例2: readTimestamp
import org.hsqldb.HsqlDateTime; //导入依赖的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);
}
示例3: logContext
import org.hsqldb.HsqlDateTime; //导入依赖的package包/类
public synchronized void logContext(int atLevel, String message) {
if (level < atLevel) {
return;
}
if (writer == null) {
return;
}
sb.append(HsqlDateTime.getSystemTimeString()).append(' ');
if (!isSQL) {
sb.append(logTypeNames[atLevel]).append(' ');
}
sb.append(message);
writer.println(sb.toString());
sb.setLength(0);
writer.flush();
}
示例4: getDate
import org.hsqldb.HsqlDateTime; //导入依赖的package包/类
/**
* <!-- start generic documentation -->
* Retrieves the value of the designated column in the current row
* of this <code>ResultSet</code> object as a
* <code>java.sql.Date</code> object
* in the Java programming language.
* This method uses the given calendar to construct an appropriate
* millisecond value for the date if the underlying database does
* not store timezone information. <p>
* <!-- end generic documentation -->
*
* @param columnIndex the first column is 1, the second is 2, ...
* @param cal the <code>java.util.Calendar</code> object
* to use in constructing the date
* @return the column value as a <code>java.sql.Date</code> object;
* if the value is SQL <code>NULL</code>, the value returned is
* <code>null</code> in the Java programming language
* @exception SQLException if a database access error occurs
* @since JDK 1.2 (JDK 1.1.x developers: read the new overview for
* jdbcResultSet)
*/
// [email protected] 20020320 - comment - to do
// use new code already in jdbcPreparedStatement
public java.sql.Date getDate(int columnIndex,
Calendar cal) throws SQLException {
java.sql.Date date = getDate(columnIndex);
if (date == null) {
return null;
}
if (cal == null) {
return date;
}
cal.setTime(date);
HsqlDateTime.resetToDate(cal);
return new java.sql.Date(cal.getTime().getTime());
}
示例5: addMonths
import org.hsqldb.HsqlDateTime; //导入依赖的package包/类
/** @todo - overflow */
public static TimestampData addMonths(TimestampData source, int months) {
int n = source.getNanos();
synchronized (HsqlDateTime.tempCalGMT) {
HsqlDateTime.setTimeInMillis(HsqlDateTime.tempCalGMT,
source.getSeconds() * 1000);
HsqlDateTime.tempCalGMT.add(Calendar.MONTH, months);
TimestampData ts =
new TimestampData(HsqlDateTime.tempCalGMT.getTimeInMillis()
/ 1000, n, source.getZone());
return ts;
}
}
示例6: readTime
import org.hsqldb.HsqlDateTime; //导入依赖的package包/类
protected TimeData readTime(Type type) throws IOException {
readField();
if (value == null) {
return null;
}
if (version18) {
java.sql.Time dateTime = java.sql.Time.valueOf((String) value);
long millis =
HsqlDateTime.convertMillisFromCalendar(tempCalDefault,
dateTime.getTime());
millis = HsqlDateTime.getNormalisedTime(millis);
return new TimeData((int) millis / 1000, 0, 0);
}
return scanner.newTime((String) value);
}
示例7: readDate
import org.hsqldb.HsqlDateTime; //导入依赖的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);
}
示例8: writeTimestamp
import org.hsqldb.HsqlDateTime; //导入依赖的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());
}
}
示例9: readTimestamp
import org.hsqldb.HsqlDateTime; //导入依赖的package包/类
protected java.sql.Timestamp readTimestamp()
throws IOException, HsqlException {
String s = readString();
if (s == null) {
return null;
}
s = s.trim();
if (s.length() == 0) {
return null;
}
try {
return java.sql.Timestamp.valueOf(s);
} catch (IllegalArgumentException e) {
return HsqlDateTime.timestampValue(s);
}
}
示例10: logContext
import org.hsqldb.HsqlDateTime; //导入依赖的package包/类
public synchronized void logContext(int atLevel, String prefix,
String message, String suffix) {
if (level < atLevel) {
return;
}
if (writer == null) {
return;
}
sb.append(HsqlDateTime.getSystemTimeString()).append(' ');
if (!isSQL) {
sb.append(logTypeNames[atLevel]).append(' ');
}
sb.append(prefix).append(' ');
sb.append(message).append(' ').append(suffix);
writer.println(sb.toString());
sb.setLength(0);
writer.flush();
}
示例11: writeTime
import org.hsqldb.HsqlDateTime; //导入依赖的package包/类
protected void writeTime(TimeData o, Type type) {
if (type.typeCode == Types.SQL_TIME) {
long millis = o.getSeconds() * 1000L;
millis = HsqlDateTime.convertMillisToCalendar(tempCalDefault,
millis);
writeLong(millis);
} else {
writeInt(o.getSeconds());
writeInt(o.getNanos());
writeInt(o.getZone());
}
}
示例12: truncate
import org.hsqldb.HsqlDateTime; //导入依赖的package包/类
public Object truncate(Object a, int part) {
if (a == null) {
return null;
}
long millis = getMillis(a);
millis = HsqlDateTime.getTruncatedPart(millis, part);
millis -= getZoneMillis(a);
switch (typeCode) {
case Types.SQL_TIME_WITH_TIME_ZONE :
millis = HsqlDateTime.getNormalisedTime(millis);
case Types.SQL_TIME : {
return new TimeData((int) (millis / 1000), 0,
((TimeData) a).getZone());
}
case Types.SQL_DATE :
case Types.SQL_TIMESTAMP_WITH_TIME_ZONE :
case Types.SQL_TIMESTAMP : {
return new TimestampData(millis / 1000, 0,
((TimestampData) a).getZone());
}
default :
}
throw Error.runtimeError(ErrorCode.U_S0500, "DateTimeType");
}
示例13: addMonthsSpecial
import org.hsqldb.HsqlDateTime; //导入依赖的package包/类
public Object addMonthsSpecial(Session session, Object dateTime,
int months) {
TimestampData ts = (TimestampData) dateTime;
Calendar cal = session.getCalendarGMT();
long millis = (ts.getSeconds() + ts.getZone()) * 1000;
boolean lastDay;
HsqlDateTime.setTimeInMillis(cal, millis);
cal.set(Calendar.DAY_OF_MONTH, 1);
cal.add(Calendar.MONTH, 1);
cal.add(Calendar.DAY_OF_MONTH, -1);
lastDay = millis == cal.getTimeInMillis();
HsqlDateTime.setTimeInMillis(cal, millis);
cal.add(Calendar.MONTH, months);
if (lastDay) {
cal.set(Calendar.DAY_OF_MONTH, 1);
cal.add(Calendar.MONTH, 1);
cal.add(Calendar.DAY_OF_MONTH, -1);
}
millis = cal.getTimeInMillis();
return new TimestampData(millis / 1000, 0, 0);
}
示例14: getLastDayOfMonth
import org.hsqldb.HsqlDateTime; //导入依赖的package包/类
public Object getLastDayOfMonth(Session session, Object dateTime) {
TimestampData ts = (TimestampData) dateTime;
Calendar cal = session.getCalendarGMT();
long millis = (ts.getSeconds() + ts.getZone()) * 1000;
HsqlDateTime.setTimeInMillis(cal, millis);
cal.set(Calendar.DAY_OF_MONTH, 1);
cal.add(Calendar.MONTH, 1);
cal.add(Calendar.DAY_OF_MONTH, -1);
millis = cal.getTimeInMillis();
return new TimestampData(millis / 1000, 0, 0);
}
示例15: getValue
import org.hsqldb.HsqlDateTime; //导入依赖的package包/类
public Object getValue(long seconds, int nanos, int zoneSeconds) {
switch (typeCode) {
case Types.SQL_DATE :
seconds =
HsqlDateTime.getNormalisedDate(
(seconds + zoneSeconds) * 1000) / 1000;
return new TimestampData(seconds);
case Types.SQL_TIME_WITH_TIME_ZONE :
seconds = HsqlDateTime.getNormalisedDate(seconds * 1000)
/ 1000;
return new TimeData((int) seconds, nanos, zoneSeconds);
case Types.SQL_TIME :
seconds =
HsqlDateTime.getNormalisedTime(
(seconds + zoneSeconds) * 1000) / 1000;
return new TimeData((int) seconds, nanos);
case Types.SQL_TIMESTAMP_WITH_TIME_ZONE :
return new TimestampData(seconds, nanos, zoneSeconds);
case Types.SQL_TIMESTAMP :
return new TimestampData(seconds + zoneSeconds, nanos);
default :
throw Error.runtimeError(ErrorCode.U_S0500, "DateTimeType");
}
}