本文整理了Java中org.apache.calcite.rex.RexLiteral.getTimeUnits
方法的一些代码示例,展示了RexLiteral.getTimeUnits
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。RexLiteral.getTimeUnits
方法的具体详情如下:
包路径:org.apache.calcite.rex.RexLiteral
类名称:RexLiteral
方法名:getTimeUnits
[英]Returns a list of the time units covered by an interval type such as HOUR TO SECOND. Adds MILLISECOND if the end is SECOND, to deal with fractional seconds.
[中]返回间隔类型(如小时到秒)覆盖的时间单位列表。如果终点是秒,则添加毫秒,以处理小数秒。
代码示例来源:origin: Qihoo360/Quicksql
private String intervalString(BigDecimal v) {
final List<TimeUnit> timeUnits = getTimeUnits(type.getSqlTypeName());
final StringBuilder b = new StringBuilder();
for (TimeUnit timeUnit : timeUnits) {
final BigDecimal[] result = v.divideAndRemainder(timeUnit.multiplier);
if (b.length() > 0) {
b.append(timeUnit.separator);
}
final int width = b.length() == 0 ? -1 : width(timeUnit); // don't pad 1st
pad(b, result[0].toString(), width);
v = result[1];
}
if (Util.last(timeUnits) == TimeUnit.MILLISECOND) {
while (b.toString().matches(".*\\.[0-9]*0")) {
if (b.toString().endsWith(".0")) {
b.setLength(b.length() - 2); // remove ".0"
} else {
b.setLength(b.length() - 1); // remove "0"
}
}
}
return b.toString();
}
代码示例来源:origin: org.apache.calcite/calcite-core
private String intervalString(BigDecimal v) {
final List<TimeUnit> timeUnits = getTimeUnits(type.getSqlTypeName());
final StringBuilder b = new StringBuilder();
for (TimeUnit timeUnit : timeUnits) {
final BigDecimal[] result = v.divideAndRemainder(timeUnit.multiplier);
if (b.length() > 0) {
b.append(timeUnit.separator);
}
final int width = b.length() == 0 ? -1 : width(timeUnit); // don't pad 1st
pad(b, result[0].toString(), width);
v = result[1];
}
if (Util.last(timeUnits) == TimeUnit.MILLISECOND) {
while (b.toString().matches(".*\\.[0-9]*0")) {
if (b.toString().endsWith(".0")) {
b.setLength(b.length() - 2); // remove ".0"
} else {
b.setLength(b.length() - 1); // remove "0"
}
}
}
return b.toString();
}
内容来源于网络,如有侵权,请联系作者删除!