Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
6810ead1
提交
6810ead1
authored
11月 12, 2016
作者:
Philippe Marschall
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix TestClearReferences
TestClearReferences currently fails because the fields in LocalDateTimeUtils are not final.
上级
2b07a2e3
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
69 行增加
和
43 行删除
+69
-43
LocalDateTimeUtils.java
h2/src/main/org/h2/util/LocalDateTimeUtils.java
+69
-43
没有找到文件。
h2/src/main/org/h2/util/LocalDateTimeUtils.java
浏览文件 @
6810ead1
...
@@ -10,7 +10,6 @@ package org.h2.util;
...
@@ -10,7 +10,6 @@ package org.h2.util;
import
java.lang.reflect.InvocationTargetException
;
import
java.lang.reflect.InvocationTargetException
;
import
java.lang.reflect.Method
;
import
java.lang.reflect.Method
;
import
java.sql.Date
;
import
java.sql.Date
;
import
java.sql.Time
;
import
java.util.Arrays
;
import
java.util.Arrays
;
import
java.util.concurrent.TimeUnit
;
import
java.util.concurrent.TimeUnit
;
...
@@ -51,93 +50,87 @@ import org.h2.value.ValueTimestampTimeZone;
...
@@ -51,93 +50,87 @@ import org.h2.value.ValueTimestampTimeZone;
public
class
LocalDateTimeUtils
{
public
class
LocalDateTimeUtils
{
// Class<java.time.LocalDate>
// Class<java.time.LocalDate>
private
static
Class
<?>
LOCAL_DATE
;
private
static
final
Class
<?>
LOCAL_DATE
;
// Class<java.time.LocalTime>
// Class<java.time.LocalTime>
private
static
Class
<?>
LOCAL_TIME
;
private
static
final
Class
<?>
LOCAL_TIME
;
// Class<java.time.LocalDateTime>
// Class<java.time.LocalDateTime>
private
static
Class
<?>
LOCAL_DATE_TIME
;
private
static
final
Class
<?>
LOCAL_DATE_TIME
;
// Class<java.time.OffsetDateTime>
// Class<java.time.OffsetDateTime>
private
static
Class
<?>
OFFSET_DATE_TIME
;
private
static
final
Class
<?>
OFFSET_DATE_TIME
;
// Class<java.time.ZoneOffset>
// Class<java.time.ZoneOffset>
private
static
Class
<?>
ZONE_OFFSET
;
private
static
final
Class
<?>
ZONE_OFFSET
;
// java.sql.Date#toLocalDate()
// java.sql.Date#toLocalDate()
private
static
Method
TO_LOCAL_DATE
;
private
static
final
Method
TO_LOCAL_DATE
;
// java.time.LocalTime#ofNanoOfDay()
// java.time.LocalTime#ofNanoOfDay()
private
static
Method
LOCAL_TIME_OF_NANO
;
private
static
final
Method
LOCAL_TIME_OF_NANO
;
// java.sql.Date#valueOf(LocalDate)
// java.sql.Date#valueOf(LocalDate)
private
static
Method
DATE_VALUE_OF
;
private
static
final
Method
DATE_VALUE_OF
;
// java.time.LocalTime#toNanoOfDay()
// java.time.LocalTime#toNanoOfDay()
private
static
Method
LOCAL_TIME_TO_NANO
;
private
static
final
Method
LOCAL_TIME_TO_NANO
;
// java.time.LocalDate#of(int, int, int)
// java.time.LocalDate#of(int, int, int)
private
static
Method
LOCAL_DATE_OF_YEAR_MONTH_DAY
;
private
static
final
Method
LOCAL_DATE_OF_YEAR_MONTH_DAY
;
// java.time.LocalDate#parse(CharSequence)
// java.time.LocalDate#parse(CharSequence)
private
static
Method
LOCAL_DATE_PARSE
;
private
static
final
Method
LOCAL_DATE_PARSE
;
// java.time.LocalDate#getYear()
// java.time.LocalDate#getYear()
private
static
Method
LOCAL_DATE_GET_YEAR
;
private
static
final
Method
LOCAL_DATE_GET_YEAR
;
// java.time.LocalDate#getMonthValue()
// java.time.LocalDate#getMonthValue()
private
static
Method
LOCAL_DATE_GET_MONTH_VALUE
;
private
static
final
Method
LOCAL_DATE_GET_MONTH_VALUE
;
// java.time.LocalDate#getDayOfMonth()
// java.time.LocalDate#getDayOfMonth()
private
static
Method
LOCAL_DATE_GET_DAY_OF_MONTH
;
private
static
final
Method
LOCAL_DATE_GET_DAY_OF_MONTH
;
// java.time.LocalDate#atStartOfDay()
// java.time.LocalDate#atStartOfDay()
private
static
Method
LOCAL_DATE_AT_START_OF_DAY
;
private
static
final
Method
LOCAL_DATE_AT_START_OF_DAY
;
// java.time.LocalTime#parse(CharSequence)
// java.time.LocalTime#parse(CharSequence)
private
static
Method
LOCAL_TIME_PARSE
;
private
static
final
Method
LOCAL_TIME_PARSE
;
// java.time.LocalDateTime#plusNanos(long)
// java.time.LocalDateTime#plusNanos(long)
private
static
Method
LOCAL_DATE_TIME_PLUS_NANOS
;
private
static
final
Method
LOCAL_DATE_TIME_PLUS_NANOS
;
// java.time.LocalDateTime#toLocalDate()
// java.time.LocalDateTime#toLocalDate()
private
static
Method
LOCAL_DATE_TIME_TO_LOCAL_DATE
;
private
static
final
Method
LOCAL_DATE_TIME_TO_LOCAL_DATE
;
// java.time.LocalDateTime#truncatedTo(TemporalUnit)
// java.time.LocalDateTime#truncatedTo(TemporalUnit)
private
static
Method
LOCAL_DATE_TIME_TRUNCATED_TO
;
private
static
final
Method
LOCAL_DATE_TIME_TRUNCATED_TO
;
// java.time.LocalDateTime#parse(CharSequence)
// java.time.LocalDateTime#parse(CharSequence)
private
static
Method
LOCAL_DATE_TIME_PARSE
;
private
static
final
Method
LOCAL_DATE_TIME_PARSE
;
// java.time.ZoneOffset#ofTotalSeconds(int)
// java.time.ZoneOffset#ofTotalSeconds(int)
private
static
Method
ZONE_OFFSET_OF_TOTAL_SECONDS
;
private
static
final
Method
ZONE_OFFSET_OF_TOTAL_SECONDS
;
// java.time.OffsetDateTime#of(LocalDateTime, ZoneOffset)
// java.time.OffsetDateTime#of(LocalDateTime, ZoneOffset)
private
static
Method
OFFSET_DATE_TIME_OF_LOCAL_DATE_TIME_ZONE_OFFSET
;
private
static
final
Method
OFFSET_DATE_TIME_OF_LOCAL_DATE_TIME_ZONE_OFFSET
;
// java.time.OffsetDateTime#parse(CharSequence)
// java.time.OffsetDateTime#parse(CharSequence)
private
static
Method
OFFSET_DATE_TIME_PARSE
;
private
static
final
Method
OFFSET_DATE_TIME_PARSE
;
// java.time.OffsetDateTime#toLocalDateTime()
// java.time.OffsetDateTime#toLocalDateTime()
private
static
Method
OFFSET_DATE_TIME_TO_LOCAL_DATE_TIME
;
private
static
final
Method
OFFSET_DATE_TIME_TO_LOCAL_DATE_TIME
;
// java.time.OffsetDateTime#getOffset()
// java.time.OffsetDateTime#getOffset()
private
static
Method
OFFSET_DATE_TIME_GET_OFFSET
;
private
static
final
Method
OFFSET_DATE_TIME_GET_OFFSET
;
// java.time.ZoneOffset#getTotalSeconds()
// java.time.ZoneOffset#getTotalSeconds()
private
static
Method
ZONE_OFFSET_GET_TOTAL_SECONDS
;
private
static
final
Method
ZONE_OFFSET_GET_TOTAL_SECONDS
;
// java.time.Duration#between(Temporal, Temporal)
// java.time.Duration#between(Temporal, Temporal)
private
static
Method
DURATION_BETWEEN
;
private
static
final
Method
DURATION_BETWEEN
;
// java.time.Duration#toNanos()
// java.time.Duration#toNanos()
private
static
Method
DURATION_TO_NANOS
;
private
static
final
Method
DURATION_TO_NANOS
;
// java.time.temporal.ChronoUnit#DAYS
// java.time.temporal.ChronoUnit#DAYS
private
static
Object
CHRONO_UNIT_DAYS
;
private
static
final
Object
CHRONO_UNIT_DAYS
;
private
static
final
boolean
IS_JAVA8_DATE_API_PRESENT
;
private
static
final
boolean
IS_JAVA8_DATE_API_PRESENT
;
static
{
static
{
boolean
isJava8DateApiPresent
;
LOCAL_DATE
=
tryGetClass
(
"java.time.LocalDate"
);
try
{
LOCAL_TIME
=
tryGetClass
(
"java.time.LocalTime"
);
LOCAL_DATE
=
Class
.
forName
(
"java.time.LocalDate"
);
LOCAL_DATE_TIME
=
tryGetClass
(
"java.time.LocalDateTime"
);
LOCAL_TIME
=
Class
.
forName
(
"java.time.LocalTime"
);
OFFSET_DATE_TIME
=
tryGetClass
(
"java.time.OffsetDateTime"
);
LOCAL_DATE_TIME
=
Class
.
forName
(
"java.time.LocalDateTime"
);
ZONE_OFFSET
=
tryGetClass
(
"java.time.ZoneOffset"
);
OFFSET_DATE_TIME
=
Class
.
forName
(
"java.time.OffsetDateTime"
);
IS_JAVA8_DATE_API_PRESENT
=
LOCAL_DATE
!=
null
&&
LOCAL_TIME
!=
null
ZONE_OFFSET
=
Class
.
forName
(
"java.time.ZoneOffset"
);
&&
LOCAL_DATE_TIME
!=
null
&&
OFFSET_DATE_TIME
!=
null
&&
ZONE_OFFSET
!=
null
;
isJava8DateApiPresent
=
true
;
}
catch
(
ClassNotFoundException
e
)
{
// older than Java 8
isJava8DateApiPresent
=
false
;
}
IS_JAVA8_DATE_API_PRESENT
=
isJava8DateApiPresent
;
if
(
IS_JAVA8_DATE_API_PRESENT
)
{
if
(
IS_JAVA8_DATE_API_PRESENT
)
{
...
@@ -184,6 +177,31 @@ public class LocalDateTimeUtils {
...
@@ -184,6 +177,31 @@ public class LocalDateTimeUtils {
DURATION_TO_NANOS
=
getMethod
(
duration
,
"toNanos"
);
DURATION_TO_NANOS
=
getMethod
(
duration
,
"toNanos"
);
CHRONO_UNIT_DAYS
=
getFieldValue
(
chronoUnit
,
"DAYS"
);
CHRONO_UNIT_DAYS
=
getFieldValue
(
chronoUnit
,
"DAYS"
);
}
else
{
TO_LOCAL_DATE
=
null
;
LOCAL_TIME_OF_NANO
=
null
;
DATE_VALUE_OF
=
null
;
LOCAL_TIME_TO_NANO
=
null
;
LOCAL_DATE_OF_YEAR_MONTH_DAY
=
null
;
LOCAL_DATE_PARSE
=
null
;
LOCAL_DATE_GET_YEAR
=
null
;
LOCAL_DATE_GET_MONTH_VALUE
=
null
;
LOCAL_DATE_GET_DAY_OF_MONTH
=
null
;
LOCAL_DATE_AT_START_OF_DAY
=
null
;
LOCAL_TIME_PARSE
=
null
;
LOCAL_DATE_TIME_PLUS_NANOS
=
null
;
LOCAL_DATE_TIME_TO_LOCAL_DATE
=
null
;
LOCAL_DATE_TIME_TRUNCATED_TO
=
null
;
LOCAL_DATE_TIME_PARSE
=
null
;
ZONE_OFFSET_OF_TOTAL_SECONDS
=
null
;
OFFSET_DATE_TIME_TO_LOCAL_DATE_TIME
=
null
;
OFFSET_DATE_TIME_GET_OFFSET
=
null
;
OFFSET_DATE_TIME_OF_LOCAL_DATE_TIME_ZONE_OFFSET
=
null
;
OFFSET_DATE_TIME_PARSE
=
null
;
ZONE_OFFSET_GET_TOTAL_SECONDS
=
null
;
DURATION_BETWEEN
=
null
;
DURATION_TO_NANOS
=
null
;
CHRONO_UNIT_DAYS
=
null
;
}
}
}
}
...
@@ -296,6 +314,14 @@ public class LocalDateTimeUtils {
...
@@ -296,6 +314,14 @@ public class LocalDateTimeUtils {
}
}
}
}
private
static
Class
<?>
tryGetClass
(
String
className
)
{
try
{
return
Class
.
forName
(
className
);
}
catch
(
ClassNotFoundException
e
)
{
return
null
;
}
}
private
static
Class
<?>
getClass
(
String
className
)
{
private
static
Class
<?>
getClass
(
String
className
)
{
try
{
try
{
return
Class
.
forName
(
className
);
return
Class
.
forName
(
className
);
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论