Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
c1bec064
D
dragonwell8_jdk
项目概览
openanolis
/
dragonwell8_jdk
通知
4
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dragonwell8_jdk
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
c1bec064
编写于
3月 06, 2014
作者:
S
scolebourne
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8036818: DateTimeFormatter withResolverFields() fails to accept null
Reviewed-by: chegar, rriggs Contributed-by: scolebourne@joda.org
上级
8f288c97
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
17 addition
and
9 deletion
+17
-9
src/share/classes/java/time/format/DateTimeFormatter.java
src/share/classes/java/time/format/DateTimeFormatter.java
+7
-5
test/java/time/tck/java/time/format/TCKDateTimeFormatter.java
.../java/time/tck/java/time/format/TCKDateTimeFormatter.java
+10
-4
未找到文件。
src/share/classes/java/time/format/DateTimeFormatter.java
浏览文件 @
c1bec064
...
...
@@ -1644,12 +1644,13 @@ public final class DateTimeFormatter {
* @return a formatter based on this formatter with the requested resolver style, not null
*/
public
DateTimeFormatter
withResolverFields
(
TemporalField
...
resolverFields
)
{
Objects
.
requireNonNull
(
resolverFields
,
"resolverFields"
);
Set
<
TemporalField
>
fields
=
new
HashSet
<>(
Arrays
.
asList
(
resolverFields
));
Set
<
TemporalField
>
fields
=
null
;
if
(
resolverFields
!=
null
)
{
fields
=
Collections
.
unmodifiableSet
(
new
HashSet
<>(
Arrays
.
asList
(
resolverFields
)));
}
if
(
Objects
.
equals
(
this
.
resolverFields
,
fields
))
{
return
this
;
}
fields
=
Collections
.
unmodifiableSet
(
fields
);
return
new
DateTimeFormatter
(
printerParser
,
locale
,
decimalStyle
,
resolverStyle
,
fields
,
chrono
,
zone
);
}
...
...
@@ -1693,11 +1694,12 @@ public final class DateTimeFormatter {
* @return a formatter based on this formatter with the requested resolver style, not null
*/
public
DateTimeFormatter
withResolverFields
(
Set
<
TemporalField
>
resolverFields
)
{
Objects
.
requireNonNull
(
resolverFields
,
"resolverFields"
);
if
(
Objects
.
equals
(
this
.
resolverFields
,
resolverFields
))
{
return
this
;
}
if
(
resolverFields
!=
null
)
{
resolverFields
=
Collections
.
unmodifiableSet
(
new
HashSet
<>(
resolverFields
));
}
return
new
DateTimeFormatter
(
printerParser
,
locale
,
decimalStyle
,
resolverStyle
,
resolverFields
,
chrono
,
zone
);
}
...
...
test/java/time/tck/java/time/format/TCKDateTimeFormatter.java
浏览文件 @
c1bec064
...
...
@@ -254,14 +254,20 @@ public class TCKDateTimeFormatter {
assertEquals
(
parsed
.
isSupported
(
YEAR
),
false
);
// not in the list of resolverFields
}
@Test
(
expectedExceptions
=
NullPointerException
.
class
)
@Test
public
void
test_resolverFields_Array_null
()
throws
Exception
{
DateTimeFormatter
.
ISO_DATE
.
withResolverFields
((
TemporalField
[])
null
);
DateTimeFormatter
f
=
DateTimeFormatter
.
ISO_DATE
.
withResolverFields
(
MONTH_OF_YEAR
);
assertEquals
(
f
.
getResolverFields
().
size
(),
1
);
f
=
f
.
withResolverFields
((
TemporalField
[])
null
);
assertEquals
(
f
.
getResolverFields
(),
null
);
}
@Test
(
expectedExceptions
=
NullPointerException
.
class
)
@Test
public
void
test_resolverFields_Set_null
()
throws
Exception
{
DateTimeFormatter
.
ISO_DATE
.
withResolverFields
((
Set
<
TemporalField
>)
null
);
DateTimeFormatter
f
=
DateTimeFormatter
.
ISO_DATE
.
withResolverFields
(
MONTH_OF_YEAR
);
assertEquals
(
f
.
getResolverFields
().
size
(),
1
);
f
=
f
.
withResolverFields
((
Set
<
TemporalField
>)
null
);
assertEquals
(
f
.
getResolverFields
(),
null
);
}
//-----------------------------------------------------------------------
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录