当前位置: 首页>>代码示例>>Java>>正文


Java HsqlDateTime.setTimeInMillis方法代码示例

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


在下文中一共展示了HsqlDateTime.setTimeInMillis方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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,项目名称:sstore-soft,代码行数:18,代码来源:DateTimeType.java

示例2: 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

示例3: 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

示例4: 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

示例5: subtractMonths

import org.hsqldb.HsqlDateTime; //导入方法依赖的package包/类
public static int subtractMonths(TimestampData a, TimestampData b,
                                 boolean isYear) {

    synchronized (HsqlDateTime.tempCalGMT) {
        boolean negate = false;

        if (b.getSeconds() > a.getSeconds()) {
            negate = true;

            TimestampData temp = a;

            a = b;
            b = temp;
        }

        HsqlDateTime.setTimeInMillis(HsqlDateTime.tempCalGMT,
                                     a.getSeconds() * 1000);

        int months = HsqlDateTime.tempCalGMT.get(Calendar.MONTH);
        int years  = HsqlDateTime.tempCalGMT.get(Calendar.YEAR);

        HsqlDateTime.setTimeInMillis(HsqlDateTime.tempCalGMT,
                                     b.getSeconds() * 1000);

        months -= HsqlDateTime.tempCalGMT.get(Calendar.MONTH);
        years  -= HsqlDateTime.tempCalGMT.get(Calendar.YEAR);

        if (isYear) {
            months = years * 12;
        } else {
            if (months < 0) {
                months += 12;

                years--;
            }

            months += years * 12;

            if (negate) {
                months = -months;
            }
        }

        return months;
    }
}
 
开发者ID:s-store,项目名称:sstore-soft,代码行数:47,代码来源:DateTimeType.java

示例6: subtractMonths

import org.hsqldb.HsqlDateTime; //导入方法依赖的package包/类
public static int subtractMonths(TimestampData a, TimestampData b,
                                 boolean isYear) {

    synchronized (HsqlDateTime.tempCalGMT) {
        boolean negate = false;

        if (b.getSeconds() > a.getSeconds()) {
            negate = true;

            TimestampData temp = a;

            a = b;
            b = temp;
        }

        HsqlDateTime.setTimeInMillis(HsqlDateTime.tempCalGMT,
                                     a.getSeconds() * 1000);

        int months = HsqlDateTime.tempCalGMT.get(Calendar.MONTH);
        int years  = HsqlDateTime.tempCalGMT.get(Calendar.YEAR);

        HsqlDateTime.setTimeInMillis(HsqlDateTime.tempCalGMT,
                                     b.getSeconds() * 1000);

        months -= HsqlDateTime.tempCalGMT.get(Calendar.MONTH);
        years  -= HsqlDateTime.tempCalGMT.get(Calendar.YEAR);

        if (isYear) {
            months = years * 12;
        } else {
            if (months < 0) {
                months += 12;

                years--;
            }

            months += years * 12;
        }

        if (negate) {
            months = -months;
        }

        return months;
    }
}
 
开发者ID:Julien35,项目名称:dev-courses,代码行数:47,代码来源:DateTimeType.java


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