本文整理汇总了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;
}
}
示例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);
}
示例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);
}
示例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;
}
示例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;
}
}
示例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;
}
}