public final class JapaneseEra extends Object implements Era, Serializable
日本政府は各時代の正式な名称と開始日を定めます。時代は連続しており、その日付範囲が重なることはないため、ある時代の終了日は常に次の時代の開始日の前日です。
Java SEプラットフォームでは、日本政府によって定められた明治時代以降のすべての時代がサポートされます。各時代は、整数値および名前によってプラットフォームで識別されます。of(int)
およびvalueOf(String)
メソッドを使用して各時代のJapaneseEraのシングルトン・インスタンスを取得できます。values()
メソッドは、サポートされているすべての時代のシングルトン・インスタンスを返します。
便宜上、このクラスは、values()メソッドによって返されるシングルトン・インスタンスを参照するpublic static finalフィールドをいくつか宣言します。
values()
メソッドの結果に合せて、時間の経過とともに変わる可能性があります。ただし、フィールドとシングルトン・インスタンスは必ずしも1対1で対応するとは限りません。日本政府が新しい時代を宣言し、その開始日を定めたが、正式な名称を定めない可能性があります。この場合、正式な名称が定められるまで、新しい時代を表すシングルトン・インスタンスが返す名前が定まらない可能性があります。public static finalフィールドに対応しないシングルトン・インスタンスによって返される名前に依存する場合、開発者は注意する必要があります。修飾子と型 | フィールドと説明 |
---|---|
static JapaneseEra |
HEISEI
値2を持つ「平成」時代(1989-01-08 - 2019-04-30)のシングルトン・インスタンス。
|
static JapaneseEra |
MEIJI
値-1を持つ「明治」時代(1868-01-01 - 1912-07-29)のシングルトン・インスタンス。
|
static JapaneseEra |
SHOWA
値1を持つ「昭和」時代(1926-12-25 - 1989-01-07)のシングルトン・インスタンス。
|
static JapaneseEra |
TAISHO
値0を持つ「大正」時代(1912-07-30 - 1926-12-24)のシングルトン・インスタンス。
|
修飾子と型 | メソッドと説明 |
---|---|
String |
getDisplayName(TextStyle style, Locale locale)
この紀元のテキスト表現を取得します。
|
int |
getValue()
数値の紀元の
int 値を取得します。 |
static JapaneseEra |
of(int japaneseEra)
int 値からJapaneseEra のインスタンスを取得します。 |
ValueRange |
range(TemporalField field)
指定されたフィールドの有効な値の範囲を取得します。
|
String |
toString()
オブジェクトの文字列表現を返します。
|
static JapaneseEra |
valueOf(String japaneseEra)
その名前を持つ
JapaneseEra を返します。 |
static JapaneseEra[] |
values()
JapaneseErasの配列を返します。
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
adjustInto, get, getLong, isSupported, query
public static final JapaneseEra MEIJI
public static final JapaneseEra TAISHO
public static final JapaneseEra SHOWA
public static final JapaneseEra HEISEI
public static JapaneseEra of(int japaneseEra)
int
値からJapaneseEra
のインスタンスを取得します。
1
は1970-01-01 (ISO暦体系)が含まれているため、「昭和」時代に関連付けられています。-1
と0
は、それより前の時代である明治と大正にそれぞれ関連付けられています。1
より大きい値は、平成(2
)以降の時代に関連付けられています。
values()
メソッドから返されるJapaneseEra
の各インスタンスは、このメソッドによって受け入れられるint値(Era.getValue()
を介して使用可能)を持ちます。
japaneseEra
- 表す紀元JapaneseEra
シングルトン、null以外DateTimeException
- 値が無効な場合public static JapaneseEra valueOf(String japaneseEra)
JapaneseEra
を返します。
文字列は、紀元の名前と完全に一致している必要があります。(不適切な空白文字は許可されません。)
japaneseEra
- japaneseEra名、null以外JapaneseEra
シングルトン、nullにはならないIllegalArgumentException
- 指定された名前を持つJapaneseEraがない場合public static JapaneseEra[] values()
このメソッドは、次のようにしてJapaneseEraに対して反復処理を行うために使用できます。
for (JapaneseEra c : JapaneseEra.values()) System.out.println(c);
public String getDisplayName(TextStyle style, Locale locale)
これは、紀元の識別に使用され、ユーザーへの表示に適したテキストの名前を返します。パラメータは返されるテキストとロケールのスタイルを制御します。
テキスト・マッピングが見つからない場合、数値
が返されます。
Era
のgetDisplayName
style
- 必要なテキストのスタイル、null以外locale
- 使用するロケール。null以外public int getValue()
public ValueRange range(TemporalField field)
範囲オブジェクトはフィールドの有効な最小値と最大値を表します。この紀元は、返される範囲の精度を向上するために使われます。範囲を返せない場合は、フィールドがサポートされていないか他のなんらかの理由で、例外がスローされます。
フィールドがChronoField
の場合、ここに問合せを実装します。ERA
フィールドは範囲を返します。他のすべてのChronoField
インスタンスはUnsupportedTemporalTypeException
をスローします。
フィールドがChronoField
ではない場合、このメソッドの結果は、引数としてthis
を渡してTemporalField.rangeRefinedBy(TemporalAccessor)
を呼び出すことにより取得されます。範囲を取得できるかどうかはフィールドによって決まります。
有効な和暦の紀元の範囲は、和暦体系の性質のため、時間の経過とともに変更される可能性があります。
Era
のrange
TemporalAccessor
のrange
field
- 範囲を問い合わせるフィールド、null以外DateTimeException
- フィールドの範囲を取得できない場合UnsupportedTemporalTypeException
- 単位がサポートされていない場合public String toString()
Object
toString
メソッドは、このオブジェクトを「テキストで表す」文字列を返します。この結果は、人間が読める簡潔で有益な情報であるべきです。すべてのサブクラスで、このメソッドをオーバーライドすることをお薦めします。
クラスObject
のtoString
メソッドは、オブジェクトがインスタンスになっている元のクラスの名前、アットマーク文字「@
」、およびオブジェクトのハッシュ・コードの符号なし16進数表現から構成される文字列を返します。つまり、このメソッドは次の値と等しい文字列を返します。
getClass().getName() + '@' + Integer.toHexString(hashCode())
バグまたは機能を送信
詳細なAPIリファレンスおよび開発者ドキュメントについては、Java SEのドキュメントを参照してください。そのドキュメントには、概念的な概要、用語の定義、回避方法、有効なコード例などの、開発者を対象にしたより詳細な説明が含まれています。
Copyright © 1993, 2020, Oracle and/or its affiliates. All rights reserved. Use is subject to license terms. Documentation Redistribution Policyも参照してください。