Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
f0169c88
提交
f0169c88
authored
6 年前
作者:
Evgenij Ryazanov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Extract IntervalUtils from DateTimeUtils
上级
f6a0794f
全部展开
显示空白字符变更
内嵌
并排
正在显示
11 个修改的文件
包含
882 行增加
和
838 行删除
+882
-838
Interval.java
h2/src/main/org/h2/api/Interval.java
+9
-9
Parser.java
h2/src/main/org/h2/command/Parser.java
+2
-1
AggregateDataMedian.java
h2/src/main/org/h2/expression/AggregateDataMedian.java
+4
-3
IntervalOperation.java
h2/src/main/org/h2/expression/IntervalOperation.java
+10
-9
DateTimeFunctions.java
h2/src/main/org/h2/util/DateTimeFunctions.java
+10
-10
DateTimeUtils.java
h2/src/main/org/h2/util/DateTimeUtils.java
+2
-791
IntervalUtils.java
h2/src/main/org/h2/util/IntervalUtils.java
+827
-0
LocalDateTimeUtils.java
h2/src/main/org/h2/util/LocalDateTimeUtils.java
+1
-1
Value.java
h2/src/main/org/h2/value/Value.java
+7
-6
ValueInterval.java
h2/src/main/org/h2/value/ValueInterval.java
+7
-6
TestDateTimeUtils.java
h2/src/test/org/h2/test/unit/TestDateTimeUtils.java
+3
-2
没有找到文件。
h2/src/main/org/h2/api/Interval.java
浏览文件 @
f0169c88
...
...
@@ -9,7 +9,7 @@ import static org.h2.util.DateTimeUtils.NANOS_PER_MINUTE;
import
static
org
.
h2
.
util
.
DateTimeUtils
.
NANOS_PER_SECOND
;
import
org.h2.message.DbException
;
import
org.h2.util.
DateTime
Utils
;
import
org.h2.util.
Interval
Utils
;
/**
* INTERVAL representation for result sets.
...
...
@@ -471,7 +471,7 @@ public final class Interval {
public
Interval
(
IntervalQualifier
qualifier
,
boolean
negative
,
long
leading
,
long
remaining
)
{
this
.
qualifier
=
qualifier
;
try
{
this
.
negative
=
DateTime
Utils
.
validateInterval
(
qualifier
,
negative
,
leading
,
remaining
);
this
.
negative
=
Interval
Utils
.
validateInterval
(
qualifier
,
negative
,
leading
,
remaining
);
}
catch
(
DbException
e
)
{
throw
new
IllegalArgumentException
();
}
...
...
@@ -523,7 +523,7 @@ public final class Interval {
* @return years, or 0
*/
public
long
getYears
()
{
return
DateTime
Utils
.
yearsFromInterval
(
qualifier
,
negative
,
leading
,
remaining
);
return
Interval
Utils
.
yearsFromInterval
(
qualifier
,
negative
,
leading
,
remaining
);
}
/**
...
...
@@ -532,7 +532,7 @@ public final class Interval {
* @return months, or 0
*/
public
long
getMonths
()
{
return
DateTime
Utils
.
monthsFromInterval
(
qualifier
,
negative
,
leading
,
remaining
);
return
Interval
Utils
.
monthsFromInterval
(
qualifier
,
negative
,
leading
,
remaining
);
}
/**
...
...
@@ -541,7 +541,7 @@ public final class Interval {
* @return days, or 0
*/
public
long
getDays
()
{
return
DateTime
Utils
.
daysFromInterval
(
qualifier
,
negative
,
leading
,
remaining
);
return
Interval
Utils
.
daysFromInterval
(
qualifier
,
negative
,
leading
,
remaining
);
}
/**
...
...
@@ -550,7 +550,7 @@ public final class Interval {
* @return hours, or 0
*/
public
long
getHours
()
{
return
DateTime
Utils
.
hoursFromInterval
(
qualifier
,
negative
,
leading
,
remaining
);
return
Interval
Utils
.
hoursFromInterval
(
qualifier
,
negative
,
leading
,
remaining
);
}
/**
...
...
@@ -559,7 +559,7 @@ public final class Interval {
* @return minutes, or 0
*/
public
long
getMinutes
()
{
return
DateTime
Utils
.
minutesFromInterval
(
qualifier
,
negative
,
leading
,
remaining
);
return
Interval
Utils
.
minutesFromInterval
(
qualifier
,
negative
,
leading
,
remaining
);
}
/**
...
...
@@ -599,7 +599,7 @@ public final class Interval {
* @return nanoseconds (including seconds), or 0
*/
public
long
getSecondsAndNanos
()
{
return
DateTime
Utils
.
nanosFromInterval
(
qualifier
,
negative
,
leading
,
remaining
);
return
Interval
Utils
.
nanosFromInterval
(
qualifier
,
negative
,
leading
,
remaining
);
}
@Override
...
...
@@ -628,7 +628,7 @@ public final class Interval {
@Override
public
String
toString
()
{
return
DateTime
Utils
.
intervalToString
(
qualifier
,
negative
,
leading
,
remaining
);
return
Interval
Utils
.
intervalToString
(
qualifier
,
negative
,
leading
,
remaining
);
}
}
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/command/Parser.java
浏览文件 @
f0169c88
...
...
@@ -190,6 +190,7 @@ import org.h2.table.TableFilter.TableFilterVisitor;
import
org.h2.table.TableView
;
import
org.h2.util.DateTimeFunctions
;
import
org.h2.util.DateTimeUtils
;
import
org.h2.util.IntervalUtils
;
import
org.h2.util.MathUtils
;
import
org.h2.util.ParserUtil
;
import
org.h2.util.StatementBuilder
;
...
...
@@ -3691,7 +3692,7 @@ public class Parser {
qualifier
=
IntervalQualifier
.
SECOND
;
}
try
{
return
ValueExpression
.
get
(
DateTime
Utils
.
parseInterval
(
qualifier
,
negative
,
s
));
return
ValueExpression
.
get
(
Interval
Utils
.
parseInterval
(
qualifier
,
negative
,
s
));
}
catch
(
Exception
e
)
{
throw
DbException
.
get
(
ErrorCode
.
INVALID_DATETIME_CONSTANT_2
,
e
,
"INTERVAL"
,
s
);
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/expression/AggregateDataMedian.java
浏览文件 @
f0169c88
...
...
@@ -23,6 +23,7 @@ import org.h2.table.IndexColumn;
import
org.h2.table.Table
;
import
org.h2.table.TableFilter
;
import
org.h2.util.DateTimeUtils
;
import
org.h2.util.IntervalUtils
;
import
org.h2.value.CompareMode
;
import
org.h2.value.Value
;
import
org.h2.value.ValueDate
;
...
...
@@ -261,9 +262,9 @@ class AggregateDataMedian extends AggregateDataCollecting {
case
Value
.
INTERVAL_HOUR_TO_MINUTE
:
case
Value
.
INTERVAL_HOUR_TO_SECOND
:
case
Value
.
INTERVAL_MINUTE_TO_SECOND
:
return
DateTime
Utils
.
intervalFromAbsolute
(
IntervalQualifier
.
valueOf
(
dataType
-
Value
.
INTERVAL_YEAR
),
DateTime
Utils
.
intervalToAbsolute
((
ValueInterval
)
v0
)
.
add
(
DateTime
Utils
.
intervalToAbsolute
((
ValueInterval
)
v1
)).
shiftRight
(
1
));
return
Interval
Utils
.
intervalFromAbsolute
(
IntervalQualifier
.
valueOf
(
dataType
-
Value
.
INTERVAL_YEAR
),
Interval
Utils
.
intervalToAbsolute
((
ValueInterval
)
v0
)
.
add
(
Interval
Utils
.
intervalToAbsolute
((
ValueInterval
)
v1
)).
shiftRight
(
1
));
default
:
// Just return first
return
v0
.
convertTo
(
dataType
);
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/expression/IntervalOperation.java
浏览文件 @
f0169c88
...
...
@@ -16,6 +16,7 @@ import org.h2.table.ColumnResolver;
import
org.h2.table.TableFilter
;
import
org.h2.util.DateTimeFunctions
;
import
org.h2.util.DateTimeUtils
;
import
org.h2.util.IntervalUtils
;
import
org.h2.value.DataType
;
import
org.h2.value.Value
;
import
org.h2.value.ValueDate
;
...
...
@@ -131,9 +132,9 @@ public class IntervalOperation extends Expression {
switch
(
opType
)
{
case
INTERVAL_PLUS_INTERVAL:
case
INTERVAL_MINUS_INTERVAL:
{
BigInteger
a1
=
DateTime
Utils
.
intervalToAbsolute
((
ValueInterval
)
l
);
BigInteger
a2
=
DateTime
Utils
.
intervalToAbsolute
((
ValueInterval
)
r
);
return
DateTime
Utils
.
intervalFromAbsolute
(
BigInteger
a1
=
Interval
Utils
.
intervalToAbsolute
((
ValueInterval
)
l
);
BigInteger
a2
=
Interval
Utils
.
intervalToAbsolute
((
ValueInterval
)
r
);
return
Interval
Utils
.
intervalFromAbsolute
(
IntervalQualifier
.
valueOf
(
Value
.
getHigherOrder
(
lType
,
rType
)
-
Value
.
INTERVAL_YEAR
),
opType
==
IntervalOpType
.
INTERVAL_PLUS_INTERVAL
?
a1
.
add
(
a2
)
:
a1
.
subtract
(
a2
));
}
...
...
@@ -142,9 +143,9 @@ public class IntervalOperation extends Expression {
return
getDateTimeWithInterval
(
l
,
r
,
lType
,
rType
);
case
INTERVAL_MULTIPLY_NUMERIC:
case
INTERVAL_DIVIDE_NUMERIC:
{
BigDecimal
a1
=
new
BigDecimal
(
DateTime
Utils
.
intervalToAbsolute
((
ValueInterval
)
l
));
BigDecimal
a1
=
new
BigDecimal
(
Interval
Utils
.
intervalToAbsolute
((
ValueInterval
)
l
));
BigDecimal
a2
=
r
.
getBigDecimal
();
return
DateTime
Utils
.
intervalFromAbsolute
(
IntervalQualifier
.
valueOf
(
lType
-
Value
.
INTERVAL_YEAR
),
return
Interval
Utils
.
intervalFromAbsolute
(
IntervalQualifier
.
valueOf
(
lType
-
Value
.
INTERVAL_YEAR
),
(
opType
==
IntervalOpType
.
INTERVAL_MULTIPLY_NUMERIC
?
a1
.
multiply
(
a2
)
:
a1
.
divide
(
a2
))
.
toBigInteger
());
}
...
...
@@ -179,7 +180,7 @@ public class IntervalOperation extends Expression {
diff
=
diff
.
add
(
BigInteger
.
valueOf
((((
ValueTimestampTimeZone
)
r
).
getTimeZoneOffsetMins
()
-
((
ValueTimestampTimeZone
)
l
).
getTimeZoneOffsetMins
())
*
60_000_000_000L
));
}
return
DateTime
Utils
.
intervalFromAbsolute
(
IntervalQualifier
.
DAY_TO_SECOND
,
diff
);
return
Interval
Utils
.
intervalFromAbsolute
(
IntervalQualifier
.
DAY_TO_SECOND
,
diff
);
}
}
throw
DbException
.
throwInternalError
(
"type="
+
opType
);
...
...
@@ -192,7 +193,7 @@ public class IntervalOperation extends Expression {
throw
DbException
.
throwInternalError
(
"type="
+
rType
);
}
BigInteger
a1
=
BigInteger
.
valueOf
(((
ValueTime
)
l
).
getNanos
());
BigInteger
a2
=
DateTime
Utils
.
intervalToAbsolute
((
ValueInterval
)
r
);
BigInteger
a2
=
Interval
Utils
.
intervalToAbsolute
((
ValueInterval
)
r
);
BigInteger
n
=
opType
==
IntervalOpType
.
DATETIME_PLUS_INTERVAL
?
a1
.
add
(
a2
)
:
a1
.
subtract
(
a2
);
if
(
n
.
signum
()
<
0
||
n
.
compareTo
(
BigInteger
.
valueOf
(
DateTimeUtils
.
NANOS_PER_DAY
))
>=
0
)
{
throw
DbException
.
get
(
ErrorCode
.
NUMERIC_VALUE_OUT_OF_RANGE_1
,
n
.
toString
());
...
...
@@ -203,13 +204,13 @@ public class IntervalOperation extends Expression {
case
Value
.
TIMESTAMP
:
case
Value
.
TIMESTAMP_TZ
:
if
(
DataType
.
isYearMonthIntervalType
(
rType
))
{
long
m
=
DateTime
Utils
.
intervalToAbsolute
((
ValueInterval
)
r
).
longValue
();
long
m
=
Interval
Utils
.
intervalToAbsolute
((
ValueInterval
)
r
).
longValue
();
if
(
opType
==
IntervalOpType
.
DATETIME_MINUS_INTERVAL
)
{
m
=
-
m
;
}
return
DateTimeFunctions
.
dateadd
(
"MONTH"
,
m
,
l
);
}
else
{
BigInteger
a2
=
DateTime
Utils
.
intervalToAbsolute
((
ValueInterval
)
r
);
BigInteger
a2
=
Interval
Utils
.
intervalToAbsolute
((
ValueInterval
)
r
);
if
(
lType
==
Value
.
DATE
)
{
BigInteger
a1
=
BigInteger
.
valueOf
(
DateTimeUtils
.
absoluteDayFromDateValue
(((
ValueDate
)
l
).
getDateValue
()));
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/util/DateTimeFunctions.java
浏览文件 @
f0169c88
...
...
@@ -355,7 +355,7 @@ public final class DateTimeFunctions {
bd
=
bd
.
negate
();
}
}
else
{
bd
=
new
BigDecimal
(
DateTime
Utils
.
intervalToAbsolute
(
interval
))
bd
=
new
BigDecimal
(
Interval
Utils
.
intervalToAbsolute
(
interval
))
.
divide
(
BigDecimal
.
valueOf
(
NANOS_PER_SECOND
));
}
return
ValueDecimal
.
get
(
bd
);
...
...
@@ -634,33 +634,33 @@ public final class DateTimeFunctions {
long
v
;
switch
(
field
)
{
case
YEAR:
v
=
DateTime
Utils
.
yearsFromInterval
(
qualifier
,
negative
,
leading
,
remaining
);
v
=
Interval
Utils
.
yearsFromInterval
(
qualifier
,
negative
,
leading
,
remaining
);
break
;
case
MONTH:
v
=
DateTime
Utils
.
monthsFromInterval
(
qualifier
,
negative
,
leading
,
remaining
);
v
=
Interval
Utils
.
monthsFromInterval
(
qualifier
,
negative
,
leading
,
remaining
);
break
;
case
DAY_OF_MONTH:
case
DAY_OF_WEEK:
case
DAY_OF_YEAR:
v
=
DateTime
Utils
.
daysFromInterval
(
qualifier
,
negative
,
leading
,
remaining
);
v
=
Interval
Utils
.
daysFromInterval
(
qualifier
,
negative
,
leading
,
remaining
);
break
;
case
HOUR:
v
=
DateTime
Utils
.
hoursFromInterval
(
qualifier
,
negative
,
leading
,
remaining
);
v
=
Interval
Utils
.
hoursFromInterval
(
qualifier
,
negative
,
leading
,
remaining
);
break
;
case
MINUTE:
v
=
DateTime
Utils
.
minutesFromInterval
(
qualifier
,
negative
,
leading
,
remaining
);
v
=
Interval
Utils
.
minutesFromInterval
(
qualifier
,
negative
,
leading
,
remaining
);
break
;
case
SECOND:
v
=
DateTime
Utils
.
nanosFromInterval
(
qualifier
,
negative
,
leading
,
remaining
)
/
NANOS_PER_SECOND
;
v
=
Interval
Utils
.
nanosFromInterval
(
qualifier
,
negative
,
leading
,
remaining
)
/
NANOS_PER_SECOND
;
break
;
case
MILLISECOND:
v
=
DateTime
Utils
.
nanosFromInterval
(
qualifier
,
negative
,
leading
,
remaining
)
/
1_000_000
%
1_000
;
v
=
Interval
Utils
.
nanosFromInterval
(
qualifier
,
negative
,
leading
,
remaining
)
/
1_000_000
%
1_000
;
break
;
case
MICROSECOND:
v
=
DateTime
Utils
.
nanosFromInterval
(
qualifier
,
negative
,
leading
,
remaining
)
/
1_000
%
1_000_000
;
v
=
Interval
Utils
.
nanosFromInterval
(
qualifier
,
negative
,
leading
,
remaining
)
/
1_000
%
1_000_000
;
break
;
case
NANOSECOND:
v
=
DateTime
Utils
.
nanosFromInterval
(
qualifier
,
negative
,
leading
,
remaining
)
%
NANOS_PER_SECOND
;
v
=
Interval
Utils
.
nanosFromInterval
(
qualifier
,
negative
,
leading
,
remaining
)
%
NANOS_PER_SECOND
;
break
;
default
:
throw
DbException
.
getUnsupportedException
(
"getDatePart("
+
date
+
", "
+
field
+
')'
);
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/util/DateTimeUtils.java
浏览文件 @
f0169c88
差异被折叠。
点击展开。
h2/src/main/org/h2/util/IntervalUtils.java
0 → 100644
浏览文件 @
f0169c88
差异被折叠。
点击展开。
h2/src/main/org/h2/util/LocalDateTimeUtils.java
浏览文件 @
f0169c88
...
...
@@ -397,7 +397,7 @@ public class LocalDateTimeUtils {
if
(
DataType
.
isYearMonthIntervalType
(
value
.
getType
()))
{
throw
DbException
.
get
(
ErrorCode
.
DATA_CONVERSION_ERROR_1
,
(
Throwable
)
null
,
value
.
getString
());
}
BigInteger
[]
dr
=
DateTime
Utils
.
intervalToAbsolute
((
ValueInterval
)
value
)
BigInteger
[]
dr
=
Interval
Utils
.
intervalToAbsolute
((
ValueInterval
)
value
)
.
divideAndRemainder
(
BigInteger
.
valueOf
(
1_000_000_000
));
try
{
return
DURATION_OF_SECONDS
.
invoke
(
null
,
dr
[
0
].
longValue
(),
dr
[
1
].
longValue
());
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/value/Value.java
浏览文件 @
f0169c88
...
...
@@ -28,6 +28,7 @@ import org.h2.store.DataHandler;
import
org.h2.tools.SimpleResultSet
;
import
org.h2.util.Bits
;
import
org.h2.util.DateTimeUtils
;
import
org.h2.util.IntervalUtils
;
import
org.h2.util.JdbcUtils
;
import
org.h2.util.MathUtils
;
import
org.h2.util.StringUtils
;
...
...
@@ -1234,7 +1235,7 @@ public abstract class Value {
case
Value
.
STRING_FIXED
:
{
String
s
=
getString
();
try
{
return
(
ValueInterval
)
DateTime
Utils
return
(
ValueInterval
)
Interval
Utils
.
parseFormattedInterval
(
IntervalQualifier
.
valueOf
(
targetType
-
Value
.
INTERVAL_YEAR
),
s
)
.
convertTo
(
targetType
);
}
catch
(
Exception
e
)
{
...
...
@@ -1244,8 +1245,8 @@ public abstract class Value {
case
Value
.
INTERVAL_YEAR
:
case
Value
.
INTERVAL_MONTH
:
case
Value
.
INTERVAL_YEAR_TO_MONTH
:
return
DateTime
Utils
.
intervalFromAbsolute
(
IntervalQualifier
.
valueOf
(
targetType
-
Value
.
INTERVAL_YEAR
),
DateTime
Utils
.
intervalToAbsolute
((
ValueInterval
)
this
));
return
Interval
Utils
.
intervalFromAbsolute
(
IntervalQualifier
.
valueOf
(
targetType
-
Value
.
INTERVAL_YEAR
),
Interval
Utils
.
intervalToAbsolute
((
ValueInterval
)
this
));
}
throw
getDataConversionError
(
targetType
);
}
...
...
@@ -1257,7 +1258,7 @@ public abstract class Value {
case
Value
.
STRING_FIXED
:
{
String
s
=
getString
();
try
{
return
(
ValueInterval
)
DateTime
Utils
return
(
ValueInterval
)
Interval
Utils
.
parseFormattedInterval
(
IntervalQualifier
.
valueOf
(
targetType
-
Value
.
INTERVAL_YEAR
),
s
)
.
convertTo
(
targetType
);
}
catch
(
Exception
e
)
{
...
...
@@ -1274,8 +1275,8 @@ public abstract class Value {
case
Value
.
INTERVAL_HOUR_TO_MINUTE
:
case
Value
.
INTERVAL_HOUR_TO_SECOND
:
case
Value
.
INTERVAL_MINUTE_TO_SECOND
:
return
DateTime
Utils
.
intervalFromAbsolute
(
IntervalQualifier
.
valueOf
(
targetType
-
Value
.
INTERVAL_YEAR
),
DateTime
Utils
.
intervalToAbsolute
((
ValueInterval
)
this
));
return
Interval
Utils
.
intervalFromAbsolute
(
IntervalQualifier
.
valueOf
(
targetType
-
Value
.
INTERVAL_YEAR
),
Interval
Utils
.
intervalToAbsolute
((
ValueInterval
)
this
));
}
throw
getDataConversionError
(
targetType
);
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/value/ValueInterval.java
浏览文件 @
f0169c88
...
...
@@ -12,6 +12,7 @@ import org.h2.api.Interval;
import
org.h2.api.IntervalQualifier
;
import
org.h2.message.DbException
;
import
org.h2.util.DateTimeUtils
;
import
org.h2.util.IntervalUtils
;
/**
* Implementation of the INTERVAL data type.
...
...
@@ -58,7 +59,7 @@ public class ValueInterval extends Value {
* @return interval value
*/
public
static
ValueInterval
from
(
IntervalQualifier
qualifier
,
boolean
negative
,
long
leading
,
long
remaining
)
{
negative
=
DateTime
Utils
.
validateInterval
(
qualifier
,
negative
,
leading
,
remaining
);
negative
=
Interval
Utils
.
validateInterval
(
qualifier
,
negative
,
leading
,
remaining
);
return
(
ValueInterval
)
Value
.
cache
(
new
ValueInterval
(
qualifier
.
ordinal
()
+
INTERVAL_YEAR
,
negative
,
leading
,
remaining
));
}
...
...
@@ -203,7 +204,7 @@ public class ValueInterval extends Value {
@Override
public
String
getString
()
{
return
DateTime
Utils
.
intervalToString
(
getQualifier
(),
negative
,
leading
,
remaining
);
return
Interval
Utils
.
intervalToString
(
getQualifier
(),
negative
,
leading
,
remaining
);
}
@Override
...
...
@@ -298,14 +299,14 @@ public class ValueInterval extends Value {
@Override
public
Value
add
(
Value
v
)
{
return
DateTime
Utils
.
intervalFromAbsolute
(
getQualifier
(),
DateTimeUtils
.
intervalToAbsolute
(
this
).
add
(
DateTime
Utils
.
intervalToAbsolute
((
ValueInterval
)
v
)));
return
Interval
Utils
.
intervalFromAbsolute
(
getQualifier
(),
IntervalUtils
.
intervalToAbsolute
(
this
).
add
(
Interval
Utils
.
intervalToAbsolute
((
ValueInterval
)
v
)));
}
@Override
public
Value
subtract
(
Value
v
)
{
return
DateTime
Utils
.
intervalFromAbsolute
(
getQualifier
(),
DateTimeUtils
.
intervalToAbsolute
(
this
).
subtract
(
DateTime
Utils
.
intervalToAbsolute
((
ValueInterval
)
v
)));
return
Interval
Utils
.
intervalFromAbsolute
(
getQualifier
(),
IntervalUtils
.
intervalToAbsolute
(
this
).
subtract
(
Interval
Utils
.
intervalToAbsolute
((
ValueInterval
)
v
)));
}
@Override
...
...
This diff is collapsed.
Click to expand it.
h2/src/test/org/h2/test/unit/TestDateTimeUtils.java
浏览文件 @
f0169c88
...
...
@@ -15,11 +15,12 @@ import java.util.TimeZone;
import
org.h2.api.IntervalQualifier
;
import
org.h2.test.TestBase
;
import
org.h2.util.DateTimeUtils
;
import
org.h2.util.IntervalUtils
;
import
org.h2.value.ValueInterval
;
import
org.h2.value.ValueTimestamp
;
/**
* Unit tests for the DateTimeUtils
class
* Unit tests for the DateTimeUtils
and IntervalUtils classes.
*/
public
class
TestDateTimeUtils
extends
TestBase
{
...
...
@@ -257,7 +258,7 @@ public class TestDateTimeUtils extends TestBase {
private
void
testParseIntervalImpl
(
IntervalQualifier
qualifier
,
boolean
negative
,
long
leading
,
long
remaining
,
String
s
,
String
full
)
{
ValueInterval
expected
=
ValueInterval
.
from
(
qualifier
,
negative
,
leading
,
remaining
);
assertEquals
(
expected
,
DateTime
Utils
.
parseInterval
(
qualifier
,
negative
,
s
));
assertEquals
(
expected
,
Interval
Utils
.
parseInterval
(
qualifier
,
negative
,
s
));
StringBuilder
b
=
new
StringBuilder
();
b
.
append
(
"INTERVAL "
).
append
(
'\''
);
if
(
negative
)
{
...
...
This diff is collapsed.
Click to expand it.
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论