Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
9cb6e331
提交
9cb6e331
authored
12月 11, 2018
作者:
Evgenij Ryazanov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Rename methods
上级
20103f32
隐藏空白字符变更
内嵌
并排
正在显示
7 个修改的文件
包含
21 行增加
和
20 行删除
+21
-20
DateTimeUtils.java
h2/src/main/org/h2/util/DateTimeUtils.java
+4
-4
Value.java
h2/src/main/org/h2/value/Value.java
+3
-2
ValueDate.java
h2/src/main/org/h2/value/ValueDate.java
+2
-2
ValueTime.java
h2/src/main/org/h2/value/ValueTime.java
+2
-2
ValueTimestamp.java
h2/src/main/org/h2/value/ValueTimestamp.java
+6
-6
TestDate.java
h2/src/test/org/h2/test/unit/TestDate.java
+2
-2
TestDateTimeUtils.java
h2/src/test/org/h2/test/unit/TestDateTimeUtils.java
+2
-2
没有找到文件。
h2/src/main/org/h2/util/DateTimeUtils.java
浏览文件 @
9cb6e331
...
...
@@ -570,8 +570,8 @@ public class DateTimeUtils {
}
else
{
long
millis
=
convertDateTimeValueToMillis
(
tz
,
dateValue
,
nanos
/
1_000_000
);
millis
+=
getTimeZoneOffset
(
millis
);
dateValue
=
dateValueFrom
Date
(
millis
);
nanos
=
nanos
%
1_000_000
+
nanosFrom
Date
(
millis
);
dateValue
=
dateValueFrom
LocalMillis
(
millis
);
nanos
=
nanos
%
1_000_000
+
nanosFrom
LocalMillis
(
millis
);
}
}
}
...
...
@@ -1126,7 +1126,7 @@ public class DateTimeUtils {
* @param ms the milliseconds
* @return the date value
*/
public
static
long
dateValueFrom
Date
(
long
ms
)
{
public
static
long
dateValueFrom
LocalMillis
(
long
ms
)
{
long
absoluteDay
=
ms
/
MILLIS_PER_DAY
;
// Round toward negative infinity
if
(
ms
<
0
&&
(
absoluteDay
*
MILLIS_PER_DAY
!=
ms
))
{
...
...
@@ -1157,7 +1157,7 @@ public class DateTimeUtils {
* @param ms the milliseconds
* @return the nanoseconds
*/
public
static
long
nanosFrom
Date
(
long
ms
)
{
public
static
long
nanosFrom
LocalMillis
(
long
ms
)
{
long
absoluteDay
=
ms
/
MILLIS_PER_DAY
;
// Round toward negative infinity
if
(
ms
<
0
&&
(
absoluteDay
*
MILLIS_PER_DAY
!=
ms
))
{
...
...
h2/src/main/org/h2/value/Value.java
浏览文件 @
9cb6e331
...
...
@@ -1043,8 +1043,9 @@ public abstract class Value {
ValueTimestampTimeZone
ts
=
(
ValueTimestampTimeZone
)
this
;
long
dateValue
=
ts
.
getDateValue
(),
timeNanos
=
ts
.
getTimeNanos
();
long
millis
=
DateTimeUtils
.
getMillis
(
dateValue
,
timeNanos
,
ts
.
getTimeZoneOffsetMins
());
return
ValueTime
.
fromNanos
(
DateTimeUtils
.
nanosFromDate
(
millis
+
DateTimeUtils
.
getTimeZoneOffset
(
millis
))
+
timeNanos
%
1_000_000
);
return
ValueTime
.
fromNanos
(
DateTimeUtils
.
nanosFromLocalMillis
(
millis
+
DateTimeUtils
.
getTimeZoneOffset
(
millis
))
+
timeNanos
%
1_000_000
);
}
case
ENUM:
throw
getDataConversionError
(
TIME
);
...
...
h2/src/main/org/h2/value/ValueDate.java
浏览文件 @
9cb6e331
...
...
@@ -48,7 +48,7 @@ public class ValueDate extends Value {
*/
public
static
ValueDate
get
(
Date
date
)
{
long
ms
=
date
.
getTime
();
return
fromDateValue
(
DateTimeUtils
.
dateValueFrom
Date
(
ms
+
DateTimeUtils
.
getTimeZoneOffset
(
ms
)));
return
fromDateValue
(
DateTimeUtils
.
dateValueFrom
LocalMillis
(
ms
+
DateTimeUtils
.
getTimeZoneOffset
(
ms
)));
}
/**
...
...
@@ -59,7 +59,7 @@ public class ValueDate extends Value {
* @return the value
*/
public
static
ValueDate
fromMillis
(
long
ms
)
{
return
fromDateValue
(
DateTimeUtils
.
dateValueFrom
Date
(
ms
+
DateTimeUtils
.
getTimeZoneOffset
(
ms
)));
return
fromDateValue
(
DateTimeUtils
.
dateValueFrom
LocalMillis
(
ms
+
DateTimeUtils
.
getTimeZoneOffset
(
ms
)));
}
/**
...
...
h2/src/main/org/h2/value/ValueTime.java
浏览文件 @
9cb6e331
...
...
@@ -85,7 +85,7 @@ public class ValueTime extends Value {
*/
public
static
ValueTime
get
(
Time
time
)
{
long
ms
=
time
.
getTime
();
return
fromNanos
(
DateTimeUtils
.
nanosFrom
Date
(
ms
+
DateTimeUtils
.
getTimeZoneOffset
(
ms
)));
return
fromNanos
(
DateTimeUtils
.
nanosFrom
LocalMillis
(
ms
+
DateTimeUtils
.
getTimeZoneOffset
(
ms
)));
}
/**
...
...
@@ -96,7 +96,7 @@ public class ValueTime extends Value {
* @return the value
*/
public
static
ValueTime
fromMillis
(
long
ms
)
{
return
fromNanos
(
DateTimeUtils
.
nanosFrom
Date
(
ms
+
DateTimeUtils
.
getTimeZoneOffset
(
ms
)));
return
fromNanos
(
DateTimeUtils
.
nanosFrom
LocalMillis
(
ms
+
DateTimeUtils
.
getTimeZoneOffset
(
ms
)));
}
/**
...
...
h2/src/main/org/h2/value/ValueTimestamp.java
浏览文件 @
9cb6e331
...
...
@@ -90,8 +90,8 @@ public class ValueTimestamp extends Value {
long
ms
=
timestamp
.
getTime
();
long
nanos
=
timestamp
.
getNanos
()
%
1_000_000
;
ms
+=
DateTimeUtils
.
getTimeZoneOffset
(
ms
);
long
dateValue
=
DateTimeUtils
.
dateValueFrom
Date
(
ms
);
nanos
+=
DateTimeUtils
.
nanosFrom
Date
(
ms
);
long
dateValue
=
DateTimeUtils
.
dateValueFrom
LocalMillis
(
ms
);
nanos
+=
DateTimeUtils
.
nanosFrom
LocalMillis
(
ms
);
return
fromDateValueAndNanos
(
dateValue
,
nanos
);
}
...
...
@@ -104,8 +104,8 @@ public class ValueTimestamp extends Value {
*/
public
static
ValueTimestamp
fromMillisNanos
(
long
ms
,
int
nanos
)
{
ms
+=
DateTimeUtils
.
getTimeZoneOffset
(
ms
);
long
dateValue
=
DateTimeUtils
.
dateValueFrom
Date
(
ms
);
long
timeNanos
=
nanos
+
DateTimeUtils
.
nanosFrom
Date
(
ms
);
long
dateValue
=
DateTimeUtils
.
dateValueFrom
LocalMillis
(
ms
);
long
timeNanos
=
nanos
+
DateTimeUtils
.
nanosFrom
LocalMillis
(
ms
);
return
fromDateValueAndNanos
(
dateValue
,
timeNanos
);
}
...
...
@@ -117,8 +117,8 @@ public class ValueTimestamp extends Value {
*/
public
static
ValueTimestamp
fromMillis
(
long
ms
)
{
ms
+=
DateTimeUtils
.
getTimeZoneOffset
(
ms
);
long
dateValue
=
DateTimeUtils
.
dateValueFrom
Date
(
ms
);
long
nanos
=
DateTimeUtils
.
nanosFrom
Date
(
ms
);
long
dateValue
=
DateTimeUtils
.
dateValueFrom
LocalMillis
(
ms
);
long
nanos
=
DateTimeUtils
.
nanosFrom
LocalMillis
(
ms
);
return
fromDateValueAndNanos
(
dateValue
,
nanos
);
}
...
...
h2/src/test/org/h2/test/unit/TestDate.java
浏览文件 @
9cb6e331
...
...
@@ -464,8 +464,8 @@ public class TestDate extends TestBase {
long
millis
=
1407437460000L
;
long
ms
=
DateTimeUtils
.
getTimeUTCWithoutDst
(
millis
);
ms
+=
DateTimeUtils
.
getTimeZoneOffset
(
ms
);
long
result1
=
DateTimeUtils
.
nanosFrom
Date
(
ms
);
long
result2
=
DateTimeUtils
.
nanosFrom
Date
(
ms
);
long
result1
=
DateTimeUtils
.
nanosFrom
LocalMillis
(
ms
);
long
result2
=
DateTimeUtils
.
nanosFrom
LocalMillis
(
ms
);
assertEquals
(
result1
,
result2
);
}
...
...
h2/src/test/org/h2/test/unit/TestDateTimeUtils.java
浏览文件 @
9cb6e331
...
...
@@ -160,8 +160,8 @@ public class TestDateTimeUtils extends TestBase {
long
timeMillis
=
gc
.
getTimeInMillis
();
ValueTimestamp
ts
=
DateTimeUtils
.
convertTimestamp
(
new
Timestamp
(
timeMillis
),
gc
);
timeMillis
+=
DateTimeUtils
.
getTimeZoneOffset
(
timeMillis
);
assertEquals
(
ts
.
getDateValue
(),
DateTimeUtils
.
dateValueFrom
Date
(
timeMillis
));
assertEquals
(
ts
.
getTimeNanos
(),
DateTimeUtils
.
nanosFrom
Date
(
timeMillis
));
assertEquals
(
ts
.
getDateValue
(),
DateTimeUtils
.
dateValueFrom
LocalMillis
(
timeMillis
));
assertEquals
(
ts
.
getTimeNanos
(),
DateTimeUtils
.
nanosFrom
LocalMillis
(
timeMillis
));
}
}
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论