本文整理汇总了Java中org.hsqldb.HsqlDateTime.tempCalGMT方法的典型用法代码示例。如果您正苦于以下问题:Java HsqlDateTime.tempCalGMT方法的具体用法?Java HsqlDateTime.tempCalGMT怎么用?Java HsqlDateTime.tempCalGMT使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.hsqldb.HsqlDateTime
的用法示例。
在下文中一共展示了HsqlDateTime.tempCalGMT方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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;
}
}
示例3: 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;
}
}