Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
a124b07e
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看板
提交
a124b07e
编写于
12月 15, 2016
作者:
O
okutsu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8054214: JapaneseEra.getDisplayName doesn't return names if it's an additional era
Reviewed-by: rriggs, naoto
上级
8b0efd7e
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
32 addition
and
8 deletion
+32
-8
src/share/classes/java/time/chrono/JapaneseEra.java
src/share/classes/java/time/chrono/JapaneseEra.java
+32
-8
未找到文件。
src/share/classes/java/time/chrono/JapaneseEra.java
浏览文件 @
a124b07e
/*
* Copyright (c) 2012, 201
3
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 201
6
, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
...
...
@@ -73,11 +73,13 @@ import java.io.ObjectStreamException;
import
java.io.Serializable
;
import
java.time.DateTimeException
;
import
java.time.LocalDate
;
import
java.time.format.TextStyle
;
import
java.time.temporal.ChronoField
;
import
java.time.temporal.TemporalField
;
import
java.time.temporal.UnsupportedTemporalTypeException
;
import
java.time.temporal.ValueRange
;
import
java.util.Arrays
;
import
java.util.Locale
;
import
java.util.Objects
;
import
sun.util.calendar.CalendarDate
;
...
...
@@ -125,8 +127,8 @@ public final class JapaneseEra
*/
public
static
final
JapaneseEra
HEISEI
=
new
JapaneseEra
(
2
,
LocalDate
.
of
(
1989
,
1
,
8
));
//
the number of
defined JapaneseEra constants.
// There
could be an extra era defined in its configuration
.
//
The number of pre
defined JapaneseEra constants.
// There
may be a supplemental era defined by the property
.
private
static
final
int
N_ERA_CONSTANTS
=
HEISEI
.
getValue
()
+
ERA_OFFSET
;
/**
...
...
@@ -236,6 +238,32 @@ public final class JapaneseEra
return
Arrays
.
copyOf
(
KNOWN_ERAS
,
KNOWN_ERAS
.
length
);
}
/**
* Gets the textual representation of this era.
* <p>
* This returns the textual name used to identify the era,
* suitable for presentation to the user.
* The parameters control the style of the returned text and the locale.
* <p>
* If no textual mapping is found then the {@link #getValue() numeric value}
* is returned.
*
* @param style the style of the text required, not null
* @param locale the locale to use, not null
* @return the text value of the era, not null
* @since 9
*/
@Override
public
String
getDisplayName
(
TextStyle
style
,
Locale
locale
)
{
// If this JapaneseEra is a supplemental one, obtain the name from
// the era definition.
if
(
getValue
()
>
N_ERA_CONSTANTS
-
ERA_OFFSET
)
{
Objects
.
requireNonNull
(
locale
,
"locale"
);
return
style
.
asNormal
()
==
TextStyle
.
NARROW
?
getAbbreviation
()
:
getName
();
}
return
Era
.
super
.
getDisplayName
(
style
,
locale
);
}
//-----------------------------------------------------------------------
/**
* Obtains an instance of {@code JapaneseEra} from a date.
...
...
@@ -337,11 +365,7 @@ public final class JapaneseEra
//-----------------------------------------------------------------------
String
getAbbreviation
()
{
int
index
=
ordinal
(
getValue
());
if
(
index
==
0
)
{
return
""
;
}
return
ERA_CONFIG
[
index
].
getAbbreviation
();
return
ERA_CONFIG
[
ordinal
(
getValue
())].
getAbbreviation
();
}
String
getName
()
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录