• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java HsqlDateTime类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.hsqldb.HsqlDateTime的典型用法代码示例。如果您正苦于以下问题:Java HsqlDateTime类的具体用法?Java HsqlDateTime怎么用?Java HsqlDateTime使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



HsqlDateTime类属于org.hsqldb包,在下文中一共展示了HsqlDateTime类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
    }
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:21,代码来源:SimpleLog.java


示例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);
    }
 
开发者ID:tiweGH,项目名称:OpenDiabetes,代码行数:24,代码来源:RowInputTextLog.java


示例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();
    }
 
开发者ID:tiweGH,项目名称:OpenDiabetes,代码行数:22,代码来源:SimpleLog.java


示例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());
    }
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:43,代码来源:jdbcResultSet.java


示例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;
    }
}
 
开发者ID:s-store,项目名称:s-store,代码行数:18,代码来源:DateTimeType.java


示例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);
    }
 
开发者ID:Julien35,项目名称:dev-courses,代码行数:22,代码来源:RowInputTextLog.java


示例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);
    }
 
开发者ID:Julien35,项目名称:dev-courses,代码行数:22,代码来源:RowInputTextLog.java


示例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());
        }
    }
 
开发者ID:Julien35,项目名称:dev-courses,代码行数:17,代码来源:RowOutputBinary180.java


示例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);
    }
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:22,代码来源:RowInputText.java


示例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();
}
 
开发者ID:Julien35,项目名称:dev-courses,代码行数:24,代码来源:SimpleLog.java


示例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());
        }
    }
 
开发者ID:tiweGH,项目名称:OpenDiabetes,代码行数:16,代码来源:RowOutputBinary180.java


示例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");
    }
 
开发者ID:tiweGH,项目名称:OpenDiabetes,代码行数:31,代码来源:DateTimeType.java


示例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);
}
 
开发者ID:tiweGH,项目名称:OpenDiabetes,代码行数:29,代码来源:DateTimeType.java


示例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);
    }
 
开发者ID:tiweGH,项目名称:OpenDiabetes,代码行数:16,代码来源:DateTimeType.java


示例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");
        }
    }
 
开发者ID:tiweGH,项目名称:OpenDiabetes,代码行数:35,代码来源:DateTimeType.java


示例16: addMonths

import org.hsqldb.HsqlDateTime; //导入依赖的package包/类
/** @todo - overflow */
public static TimestampData addMonths(Session session,
                                      TimestampData source, int months) {

    int      n   = source.getNanos();
    Calendar cal = session.getCalendarGMT();

    HsqlDateTime.setTimeInMillis(cal, source.getSeconds() * 1000);
    cal.add(Calendar.MONTH, months);

    TimestampData ts = new TimestampData(cal.getTimeInMillis() / 1000, n,
                                         source.getZone());

    return ts;
}
 
开发者ID:tiweGH,项目名称:OpenDiabetes,代码行数:16,代码来源:DateTimeType.java


示例17: convertToDatetimeSpecial

import org.hsqldb.HsqlDateTime; //导入依赖的package包/类
public static TimestampData convertToDatetimeSpecial(
        SessionInterface session, String s, DateTimeType type) {

    switch (type.typeCode) {

        case Types.SQL_TIMESTAMP :
            if (session instanceof Session
                    && ((Session) session).database.sqlSyntaxOra) {
                String pattern;

                if (s.length() == 9) {
                    pattern = "DD-MON-YY";
                } else if (s.length() == 11) {
                    pattern = "DD-MON-YYYY";
                } else if (s.length() == 20) {
                    pattern = "DD-MON-YYYY HH24:MI:SS";
                } else if (s.length() > 20) {
                    pattern = "DD-MON-YYYY HH24:MI:SS.FF";
                } else {
                    break;
                }

                SimpleDateFormat format = session.getSimpleDateFormatGMT();

                return HsqlDateTime.toDate(s, pattern, format);
            }

        //
        case Types.SQL_TIMESTAMP_WITH_TIME_ZONE :

        //
        case Types.SQL_DATE :
        case Types.SQL_TIME :
        case Types.SQL_TIME_WITH_TIME_ZONE :
        default :
    }

    throw Error.error(ErrorCode.X_22007);
}
 
开发者ID:tiweGH,项目名称:OpenDiabetes,代码行数:40,代码来源:DateTimeType.java


示例18: subtract

import org.hsqldb.HsqlDateTime; //导入依赖的package包/类
private IntervalSecondData subtract(long aSeconds, long bSeconds,
                                    long nanos) {

    if (endIntervalType != Types.SQL_INTERVAL_SECOND) {
        aSeconds =
            HsqlDateTime.getTruncatedPart(aSeconds * 1000, endIntervalType)
            / 1000;
        bSeconds =
            HsqlDateTime.getTruncatedPart(bSeconds * 1000, endIntervalType)
            / 1000;
        nanos = 0;
    }

    return new IntervalSecondData(aSeconds - bSeconds, nanos, this, true);
}
 
开发者ID:tiweGH,项目名称:OpenDiabetes,代码行数:16,代码来源:IntervalType.java


示例19: 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.";
}
 
开发者ID:s-store,项目名称:sstore-soft,代码行数:15,代码来源:LockFile.java


示例20: 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 <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);
}
 
开发者ID:s-store,项目名称:sstore-soft,代码行数:50,代码来源:JDBCPreparedStatement.java



注:本文中的org.hsqldb.HsqlDateTime类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ConnectionCreationTool类代码示例发布时间:2022-05-22
下一篇:
Java MethodNotSupportedException类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap