Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
1814f24d
提交
1814f24d
authored
1月 15, 2018
作者:
Evgenij Ryazanov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add constant DateTimeUtils.UTC
上级
95bc8bb4
隐藏空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
13 行增加
和
9 行删除
+13
-9
Function.java
h2/src/main/org/h2/expression/Function.java
+1
-1
WebServer.java
h2/src/main/org/h2/server/web/WebServer.java
+2
-1
DateTimeUtils.java
h2/src/main/org/h2/util/DateTimeUtils.java
+5
-0
ValueTimestamp.java
h2/src/main/org/h2/value/ValueTimestamp.java
+1
-1
ValueTimestampTimeZone.java
h2/src/main/org/h2/value/ValueTimestampTimeZone.java
+3
-5
TestDate.java
h2/src/test/org/h2/test/unit/TestDate.java
+1
-1
没有找到文件。
h2/src/main/org/h2/expression/Function.java
浏览文件 @
1814f24d
...
@@ -1926,7 +1926,7 @@ public class Function extends Expression implements FunctionCall {
...
@@ -1926,7 +1926,7 @@ public class Function extends Expression implements FunctionCall {
default
:
default
:
break
;
break
;
}
}
calendar
=
DateTimeUtils
.
createGregorianCalendar
(
TimeZone
.
getTimeZone
(
"UTC"
)
);
calendar
=
DateTimeUtils
.
createGregorianCalendar
(
DateTimeUtils
.
UTC
);
calendar
.
setTimeInMillis
(
t1
);
calendar
.
setTimeInMillis
(
t1
);
int
year1
=
calendar
.
get
(
Calendar
.
YEAR
);
int
year1
=
calendar
.
get
(
Calendar
.
YEAR
);
int
month1
=
calendar
.
get
(
Calendar
.
MONTH
);
int
month1
=
calendar
.
get
(
Calendar
.
MONTH
);
...
...
h2/src/main/org/h2/server/web/WebServer.java
浏览文件 @
1814f24d
...
@@ -31,6 +31,7 @@ import org.h2.message.DbException;
...
@@ -31,6 +31,7 @@ import org.h2.message.DbException;
import
org.h2.server.Service
;
import
org.h2.server.Service
;
import
org.h2.server.ShutdownHandler
;
import
org.h2.server.ShutdownHandler
;
import
org.h2.store.fs.FileUtils
;
import
org.h2.store.fs.FileUtils
;
import
org.h2.util.DateTimeUtils
;
import
org.h2.util.JdbcUtils
;
import
org.h2.util.JdbcUtils
;
import
org.h2.util.MathUtils
;
import
org.h2.util.MathUtils
;
import
org.h2.util.NetUtils
;
import
org.h2.util.NetUtils
;
...
@@ -257,7 +258,7 @@ public class WebServer implements Service {
...
@@ -257,7 +258,7 @@ public class WebServer implements Service {
if
(
startDateTime
==
null
)
{
if
(
startDateTime
==
null
)
{
SimpleDateFormat
format
=
new
SimpleDateFormat
(
SimpleDateFormat
format
=
new
SimpleDateFormat
(
"EEE, d MMM yyyy HH:mm:ss z"
,
new
Locale
(
"en"
,
""
));
"EEE, d MMM yyyy HH:mm:ss z"
,
new
Locale
(
"en"
,
""
));
format
.
setTimeZone
(
TimeZone
.
getTimeZone
(
"GMT"
)
);
format
.
setTimeZone
(
DateTimeUtils
.
UTC
);
startDateTime
=
format
.
format
(
System
.
currentTimeMillis
());
startDateTime
=
format
.
format
(
System
.
currentTimeMillis
());
}
}
return
startDateTime
;
return
startDateTime
;
...
...
h2/src/main/org/h2/util/DateTimeUtils.java
浏览文件 @
1814f24d
...
@@ -35,6 +35,11 @@ public class DateTimeUtils {
...
@@ -35,6 +35,11 @@ public class DateTimeUtils {
*/
*/
public
static
final
long
MILLIS_PER_DAY
=
24
*
60
*
60
*
1000L
;
public
static
final
long
MILLIS_PER_DAY
=
24
*
60
*
60
*
1000L
;
/**
* UTC time zone.
*/
public
static
final
TimeZone
UTC
=
TimeZone
.
getTimeZone
(
"UTC"
);
private
static
final
long
NANOS_PER_DAY
=
MILLIS_PER_DAY
*
1000000
;
private
static
final
long
NANOS_PER_DAY
=
MILLIS_PER_DAY
*
1000000
;
private
static
final
int
SHIFT_YEAR
=
9
;
private
static
final
int
SHIFT_YEAR
=
9
;
...
...
h2/src/main/org/h2/value/ValueTimestamp.java
浏览文件 @
1814f24d
...
@@ -172,7 +172,7 @@ public class ValueTimestamp extends Value {
...
@@ -172,7 +172,7 @@ public class ValueTimestamp extends Value {
int
timeEnd
=
s
.
length
();
int
timeEnd
=
s
.
length
();
TimeZone
tz
=
null
;
TimeZone
tz
=
null
;
if
(
s
.
endsWith
(
"Z"
))
{
if
(
s
.
endsWith
(
"Z"
))
{
tz
=
TimeZone
.
getTimeZone
(
"UTC"
)
;
tz
=
DateTimeUtils
.
UTC
;
timeEnd
--;
timeEnd
--;
}
else
{
}
else
{
int
timeZoneStart
=
s
.
indexOf
(
'+'
,
dateEnd
+
1
);
int
timeZoneStart
=
s
.
indexOf
(
'+'
,
dateEnd
+
1
);
...
...
h2/src/main/org/h2/value/ValueTimestampTimeZone.java
浏览文件 @
1814f24d
...
@@ -40,8 +40,6 @@ public class ValueTimestampTimeZone extends Value {
...
@@ -40,8 +40,6 @@ public class ValueTimestampTimeZone extends Value {
*/
*/
static
final
int
DEFAULT_SCALE
=
10
;
static
final
int
DEFAULT_SCALE
=
10
;
private
static
final
TimeZone
GMT_TIMEZONE
=
TimeZone
.
getTimeZone
(
"GMT"
);
/**
/**
* A bit field with bits for the year, month, and day (see DateTimeUtils for
* A bit field with bits for the year, month, and day (see DateTimeUtils for
* encoding)
* encoding)
...
@@ -165,7 +163,7 @@ public class ValueTimestampTimeZone extends Value {
...
@@ -165,7 +163,7 @@ public class ValueTimestampTimeZone extends Value {
}
}
if
(
tz
!=
null
)
{
if
(
tz
!=
null
)
{
long
millis
=
DateTimeUtils
long
millis
=
DateTimeUtils
.
convertDateValueToMillis
(
GMT_TIMEZONE
,
dateValue
);
.
convertDateValueToMillis
(
DateTimeUtils
.
UTC
,
dateValue
);
tzMinutes
=
(
short
)
(
tz
.
getOffset
(
millis
)
/
1000
/
60
);
tzMinutes
=
(
short
)
(
tz
.
getOffset
(
millis
)
/
1000
/
60
);
}
}
}
}
...
@@ -294,7 +292,7 @@ public class ValueTimestampTimeZone extends Value {
...
@@ -294,7 +292,7 @@ public class ValueTimestampTimeZone extends Value {
// convert to minutes and add timezone offset
// convert to minutes and add timezone offset
long
a
=
DateTimeUtils
.
convertDateValueToMillis
(
long
a
=
DateTimeUtils
.
convertDateValueToMillis
(
TimeZone
.
getTimeZone
(
"UTC"
)
,
dateValue
)
/
DateTimeUtils
.
UTC
,
dateValue
)
/
(
1000L
*
60L
);
(
1000L
*
60L
);
long
ma
=
timeNanos
/
(
1000L
*
1000L
*
1000L
*
60L
);
long
ma
=
timeNanos
/
(
1000L
*
1000L
*
1000L
*
60L
);
a
+=
ma
;
a
+=
ma
;
...
@@ -302,7 +300,7 @@ public class ValueTimestampTimeZone extends Value {
...
@@ -302,7 +300,7 @@ public class ValueTimestampTimeZone extends Value {
// convert to minutes and add timezone offset
// convert to minutes and add timezone offset
long
b
=
DateTimeUtils
.
convertDateValueToMillis
(
long
b
=
DateTimeUtils
.
convertDateValueToMillis
(
TimeZone
.
getTimeZone
(
"UTC"
)
,
t
.
dateValue
)
/
DateTimeUtils
.
UTC
,
t
.
dateValue
)
/
(
1000L
*
60L
);
(
1000L
*
60L
);
long
mb
=
t
.
timeNanos
/
(
1000L
*
1000L
*
1000L
*
60L
);
long
mb
=
t
.
timeNanos
/
(
1000L
*
1000L
*
1000L
*
60L
);
b
+=
mb
;
b
+=
mb
;
...
...
h2/src/test/org/h2/test/unit/TestDate.java
浏览文件 @
1814f24d
...
@@ -352,7 +352,7 @@ public class TestDate extends TestBase {
...
@@ -352,7 +352,7 @@ public class TestDate extends TestBase {
}
}
private
void
testValidDate
()
{
private
void
testValidDate
()
{
Calendar
c
=
DateTimeUtils
.
createGregorianCalendar
(
TimeZone
.
getTimeZone
(
"UTC"
)
);
Calendar
c
=
DateTimeUtils
.
createGregorianCalendar
(
DateTimeUtils
.
UTC
);
c
.
setLenient
(
false
);
c
.
setLenient
(
false
);
for
(
int
y
=
-
2000
;
y
<
3000
;
y
++)
{
for
(
int
y
=
-
2000
;
y
<
3000
;
y
++)
{
for
(
int
m
=
-
3
;
m
<=
14
;
m
++)
{
for
(
int
m
=
-
3
;
m
<=
14
;
m
++)
{
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论