Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
f38de87b
提交
f38de87b
authored
2月 03, 2018
作者:
Evgenij Ryazanov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Do not create a new calendar for isLeapYear() call
上级
9b90ba1f
显示空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
10 行增加
和
10 行删除
+10
-10
DateTimeUtils.java
h2/src/main/org/h2/util/DateTimeUtils.java
+10
-10
没有找到文件。
h2/src/main/org/h2/util/DateTimeUtils.java
浏览文件 @
f38de87b
...
@@ -64,12 +64,12 @@ public class DateTimeUtils {
...
@@ -64,12 +64,12 @@ public class DateTimeUtils {
* have that problem, and while it is still a small memory leak, it is not a
* have that problem, and while it is still a small memory leak, it is not a
* class loader memory leak.
* class loader memory leak.
*/
*/
private
static
final
ThreadLocal
<
Calendar
>
CACHED_CALENDAR
=
new
ThreadLocal
<>();
private
static
final
ThreadLocal
<
Gregorian
Calendar
>
CACHED_CALENDAR
=
new
ThreadLocal
<>();
/**
/**
* A cached instance of Calendar used when a timezone is specified.
* A cached instance of Calendar used when a timezone is specified.
*/
*/
private
static
final
ThreadLocal
<
Calendar
>
CACHED_CALENDAR_NON_DEFAULT_TIMEZONE
=
private
static
final
ThreadLocal
<
Gregorian
Calendar
>
CACHED_CALENDAR_NON_DEFAULT_TIMEZONE
=
new
ThreadLocal
<>();
new
ThreadLocal
<>();
/**
/**
...
@@ -101,8 +101,8 @@ public class DateTimeUtils {
...
@@ -101,8 +101,8 @@ public class DateTimeUtils {
*
*
* @return a calendar instance. A cached instance is returned where possible
* @return a calendar instance. A cached instance is returned where possible
*/
*/
private
static
Calendar
getCalendar
()
{
private
static
Gregorian
Calendar
getCalendar
()
{
Calendar
c
=
CACHED_CALENDAR
.
get
();
Gregorian
Calendar
c
=
CACHED_CALENDAR
.
get
();
if
(
c
==
null
)
{
if
(
c
==
null
)
{
c
=
DateTimeUtils
.
createGregorianCalendar
();
c
=
DateTimeUtils
.
createGregorianCalendar
();
CACHED_CALENDAR
.
set
(
c
);
CACHED_CALENDAR
.
set
(
c
);
...
@@ -117,8 +117,8 @@ public class DateTimeUtils {
...
@@ -117,8 +117,8 @@ public class DateTimeUtils {
* @param tz timezone for the calendar, is never null
* @param tz timezone for the calendar, is never null
* @return a calendar instance. A cached instance is returned where possible
* @return a calendar instance. A cached instance is returned where possible
*/
*/
private
static
Calendar
getCalendar
(
TimeZone
tz
)
{
private
static
Gregorian
Calendar
getCalendar
(
TimeZone
tz
)
{
Calendar
c
=
CACHED_CALENDAR_NON_DEFAULT_TIMEZONE
.
get
();
Gregorian
Calendar
c
=
CACHED_CALENDAR_NON_DEFAULT_TIMEZONE
.
get
();
if
(
c
==
null
||
!
c
.
getTimeZone
().
equals
(
tz
))
{
if
(
c
==
null
||
!
c
.
getTimeZone
().
equals
(
tz
))
{
c
=
DateTimeUtils
.
createGregorianCalendar
(
tz
);
c
=
DateTimeUtils
.
createGregorianCalendar
(
tz
);
CACHED_CALENDAR_NON_DEFAULT_TIMEZONE
.
set
(
c
);
CACHED_CALENDAR_NON_DEFAULT_TIMEZONE
.
set
(
c
);
...
@@ -136,7 +136,7 @@ public class DateTimeUtils {
...
@@ -136,7 +136,7 @@ public class DateTimeUtils {
*
*
* @return a new calendar instance.
* @return a new calendar instance.
*/
*/
public
static
Calendar
createGregorianCalendar
()
{
public
static
Gregorian
Calendar
createGregorianCalendar
()
{
return
new
GregorianCalendar
();
return
new
GregorianCalendar
();
}
}
...
@@ -150,7 +150,7 @@ public class DateTimeUtils {
...
@@ -150,7 +150,7 @@ public class DateTimeUtils {
* @param tz timezone for the calendar, is never null
* @param tz timezone for the calendar, is never null
* @return a new calendar instance.
* @return a new calendar instance.
*/
*/
public
static
Calendar
createGregorianCalendar
(
TimeZone
tz
)
{
public
static
Gregorian
Calendar
createGregorianCalendar
(
TimeZone
tz
)
{
return
new
GregorianCalendar
(
tz
);
return
new
GregorianCalendar
(
tz
);
}
}
...
@@ -519,7 +519,7 @@ public class DateTimeUtils {
...
@@ -519,7 +519,7 @@ public class DateTimeUtils {
*/
*/
public
static
long
getMillis
(
TimeZone
tz
,
int
year
,
int
month
,
int
day
,
public
static
long
getMillis
(
TimeZone
tz
,
int
year
,
int
month
,
int
day
,
int
hour
,
int
minute
,
int
second
,
int
millis
)
{
int
hour
,
int
minute
,
int
second
,
int
millis
)
{
Calendar
c
;
Gregorian
Calendar
c
;
if
(
tz
==
null
)
{
if
(
tz
==
null
)
{
c
=
getCalendar
();
c
=
getCalendar
();
}
else
{
}
else
{
...
@@ -539,7 +539,7 @@ public class DateTimeUtils {
...
@@ -539,7 +539,7 @@ public class DateTimeUtils {
}
else
if
(
message
.
indexOf
(
"DAY_OF_MONTH"
)
>
0
)
{
}
else
if
(
message
.
indexOf
(
"DAY_OF_MONTH"
)
>
0
)
{
int
maxDay
;
int
maxDay
;
if
(
month
==
2
)
{
if
(
month
==
2
)
{
maxDay
=
new
GregorianCalendar
()
.
isLeapYear
(
year
)
?
29
:
28
;
maxDay
=
c
.
isLeapYear
(
year
)
?
29
:
28
;
}
else
{
}
else
{
maxDay
=
30
+
((
month
+
(
month
>
7
?
1
:
0
))
&
1
);
maxDay
=
30
+
((
month
+
(
month
>
7
?
1
:
0
))
&
1
);
}
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论