Added in API level 26

JapaneseChronology

class JapaneseChronology : AbstractChronology, Serializable
kotlin.Any
   ↳ java.time.chrono.AbstractChronology
   ↳ java.time.chrono.JapaneseChronology

The Japanese Imperial calendar system.

This chronology defines the rules of the Japanese Imperial calendar system. This calendar system is primarily used in Japan. The Japanese Imperial calendar system is the same as the ISO calendar system apart from the era-based year numbering.

Japan introduced the Gregorian calendar starting with Meiji 6. Only Meiji and later eras are supported; dates before Meiji 6, January 1 are not supported.

The supported ChronoField instances are:

  • DAY_OF_WEEK
  • DAY_OF_MONTH
  • DAY_OF_YEAR
  • EPOCH_DAY
  • MONTH_OF_YEAR
  • PROLEPTIC_MONTH
  • YEAR_OF_ERA
  • YEAR
  • ERA

Summary

Public methods
JapaneseDate!
date(era: Era!, yearOfEra: Int, month: Int, dayOfMonth: Int)

Obtains a local date in Japanese calendar system from the era, year-of-era, month-of-year and day-of-month fields.

JapaneseDate!
date(prolepticYear: Int, month: Int, dayOfMonth: Int)

Obtains a local date in Japanese calendar system from the proleptic-year, month-of-year and day-of-month fields.

JapaneseDate!
date(temporal: TemporalAccessor!)

JapaneseDate!
dateEpochDay(epochDay: Long)

Obtains a local date in the Japanese calendar system from the epoch-day.

JapaneseDate!

JapaneseDate!
dateNow(zone: ZoneId!)

JapaneseDate!
dateNow(clock: Clock!)

JapaneseDate!
dateYearDay(era: Era!, yearOfEra: Int, dayOfYear: Int)

Obtains a local date in Japanese calendar system from the era, year-of-era and day-of-year fields.

JapaneseDate!
dateYearDay(prolepticYear: Int, dayOfYear: Int)

Obtains a local date in Japanese calendar system from the proleptic-year and day-of-year fields.

JapaneseEra!
eraOf(eraValue: Int)

Returns the calendar system era object from the given numeric value.

MutableList<Era!>!

String!

Gets the calendar type of the underlying calendar system - 'japanese'.

String!

Gets the ID of the chronology - 'Japanese'.

Boolean
isLeapYear(prolepticYear: Long)

Checks if the specified year is a leap year.

ChronoLocalDateTime<JapaneseDate!>!

Int
prolepticYear(era: Era!, yearOfEra: Int)

ValueRange!
range(field: ChronoField!)

JapaneseDate!
resolveDate(fieldValues: MutableMap<TemporalField!, Long!>!, resolverStyle: ResolverStyle!)

ChronoZonedDateTime<JapaneseDate!>!

ChronoZonedDateTime<JapaneseDate!>!
zonedDateTime(instant: Instant!, zone: ZoneId!)

Inherited functions
Properties
static JapaneseChronology!

Singleton instance for Japanese chronology.

Public methods

date

Added in API level 26
fun date(
    era: Era!,
    yearOfEra: Int,
    month: Int,
    dayOfMonth: Int
): JapaneseDate!

Obtains a local date in Japanese calendar system from the era, year-of-era, month-of-year and day-of-month fields.

The Japanese month and day-of-month are the same as those in the ISO calendar system. They are not reset when the era changes. For example:

6th Jan Showa 64 = ISO 1989-01-06
   7th Jan Showa 64 = ISO 1989-01-07
   8th Jan Heisei 1 = ISO 1989-01-08
   9th Jan Heisei 1 = ISO 1989-01-09
  
Parameters
era Era!: the Japanese era, not null
yearOfEra Int: the year-of-era
month Int: the month-of-year
dayOfMonth Int: the day-of-month
Return
JapaneseDate! the Japanese local date, not null
Exceptions
java.time.DateTimeException if unable to create the date
java.lang.ClassCastException if the era is not a JapaneseEra

date

Added in API level 26
fun date(
    prolepticYear: Int,
    month: Int,
    dayOfMonth: Int
): JapaneseDate!

Obtains a local date in Japanese calendar system from the proleptic-year, month-of-year and day-of-month fields.

The Japanese proleptic year, month and day-of-month are the same as those in the ISO calendar system. They are not reset when the era changes.

Parameters
prolepticYear Int: the proleptic-year
month Int: the month-of-year
dayOfMonth Int: the day-of-month
Return
JapaneseDate! the Japanese local date, not null
Exceptions
java.time.DateTimeException if unable to create the date

date

Added in API level 26
fun date(temporal: TemporalAccessor!): JapaneseDate!
Parameters
temporal TemporalAccessor!: the temporal object to convert, not null
Return
JapaneseDate! the local date in this chronology, not null
Exceptions
java.time.DateTimeException if unable to create the date

dateEpochDay

Added in API level 26
fun dateEpochDay(epochDay: Long): JapaneseDate!

Obtains a local date in the Japanese calendar system from the epoch-day.

Parameters
epochDay Long: the epoch day
Return
JapaneseDate! the Japanese local date, not null
Exceptions
java.time.DateTimeException if unable to create the date

dateNow

Added in API level 26
fun dateNow(): JapaneseDate!
Return
JapaneseDate! the current local date using the system clock and default time-zone, not null
Exceptions
java.time.DateTimeException if unable to create the date

dateNow

Added in API level 26
fun dateNow(zone: ZoneId!): JapaneseDate!
Parameters
zone ZoneId!: the zone ID to use, not null
Return
JapaneseDate! the current local date using the system clock, not null
Exceptions
java.time.DateTimeException if unable to create the date

dateNow

Added in API level 26
fun dateNow(clock: Clock!): JapaneseDate!
Parameters
clock Clock!: the clock to use, not null
Return
JapaneseDate! the current local date, not null
Exceptions
java.time.DateTimeException if unable to create the date

dateYearDay

Added in API level 26
fun dateYearDay(
    era: Era!,
    yearOfEra: Int,
    dayOfYear: Int
): JapaneseDate!

Obtains a local date in Japanese calendar system from the era, year-of-era and day-of-year fields.

The day-of-year in this factory is expressed relative to the start of the year-of-era. This definition changes the normal meaning of day-of-year only in those years where the year-of-era is reset to one due to a change in the era. For example:

6th Jan Showa 64 = day-of-year 6
   7th Jan Showa 64 = day-of-year 7
   8th Jan Heisei 1 = day-of-year 1
   9th Jan Heisei 1 = day-of-year 2
  
Parameters
era Era!: the Japanese era, not null
yearOfEra Int: the year-of-era
dayOfYear Int: the day-of-year
Return
JapaneseDate! the Japanese local date, not null
Exceptions
java.time.DateTimeException if unable to create the date
java.lang.ClassCastException if the era is not a JapaneseEra

dateYearDay

Added in API level 26
fun dateYearDay(
    prolepticYear: Int,
    dayOfYear: Int
): JapaneseDate!

Obtains a local date in Japanese calendar system from the proleptic-year and day-of-year fields.

The day-of-year in this factory is expressed relative to the start of the proleptic year. The Japanese proleptic year and day-of-year are the same as those in the ISO calendar system. They are not reset when the era changes.

Parameters
prolepticYear Int: the proleptic-year
dayOfYear Int: the day-of-year
Return
JapaneseDate! the Japanese local date, not null
Exceptions
java.time.DateTimeException if unable to create the date

eraOf

Added in API level 26
fun eraOf(eraValue: Int): JapaneseEra!

Returns the calendar system era object from the given numeric value. The numeric values supported by this method are the same as the numeric values supported by JapaneseEra#of(int).

Parameters
eraValue Int: the era value
Return
JapaneseEra! the Japanese Era for the given numeric era value
Exceptions
java.time.DateTimeException if eraValue is invalid

eras

Added in API level 26
fun eras(): MutableList<Era!>!
Return
MutableList<Era!>! the list of eras for the chronology, may be immutable, not null

getCalendarType

Added in API level 26
fun getCalendarType(): String!

Gets the calendar type of the underlying calendar system - 'japanese'.

The calendar type is an identifier defined by the Unicode Locale Data Markup Language (LDML) specification. It can be used to lookup the Chronology using Chronology#of(String). It can also be used as part of a locale, accessible via Locale#getUnicodeLocaleType(String) with the key 'ca'.

Return
String! the calendar system type - 'japanese'

See Also

getId

Added in API level 26
fun getId(): String!

Gets the ID of the chronology - 'Japanese'.

The ID uniquely identifies the Chronology. It can be used to lookup the Chronology using Chronology#of(String).

Return
String! the chronology ID - 'Japanese'

isLeapYear

Added in API level 26
fun isLeapYear(prolepticYear: Long): Boolean

Checks if the specified year is a leap year.

Japanese calendar leap years occur exactly in line with ISO leap years. This method does not validate the year passed in, and only has a well-defined result for years in the supported range.

Parameters
prolepticYear Long: the proleptic-year to check, not validated for range
Return
Boolean true if the year is a leap year

localDateTime

Added in API level 26
fun localDateTime(temporal: TemporalAccessor!): ChronoLocalDateTime<JapaneseDate!>!
Parameters
temporal TemporalAccessor!: the temporal object to convert, not null
Return
ChronoLocalDateTime<JapaneseDate!>! the local date-time in this chronology, not null
Exceptions
java.time.DateTimeException if unable to create the date-time

prolepticYear

Added in API level 26
fun prolepticYear(
    era: Era!,
    yearOfEra: Int
): Int
Parameters
era Era!: the era of the correct type for the chronology, not null
yearOfEra Int: the chronology year-of-era
Return
Int the proleptic-year
Exceptions
java.time.DateTimeException if unable to convert to a proleptic-year, such as if the year is invalid for the era
java.lang.ClassCastException if the era is not of the correct type for the chronology

range

Added in API level 26
fun range(field: ChronoField!): ValueRange!
Parameters
field ChronoField!: the field to get the range for, not null
Return
ValueRange! the range of valid values for the field, not null
Exceptions
java.time.DateTimeException if the range for the field cannot be obtained

resolveDate

Added in API level 26
fun resolveDate(
    fieldValues: MutableMap<TemporalField!, Long!>!,
    resolverStyle: ResolverStyle!
): JapaneseDate!
Parameters
fieldValues MutableMap<TemporalField!, Long!>!: the map of fields to values, which can be updated, not null
resolverStyle ResolverStyle!: the requested type of resolve, not null
Return
JapaneseDate! the resolved date, null if insufficient information to create a date
Exceptions
java.time.DateTimeException if the date cannot be resolved, typically because of a conflict in the input data

zonedDateTime

Added in API level 26
fun zonedDateTime(temporal: TemporalAccessor!): ChronoZonedDateTime<JapaneseDate!>!
Parameters
temporal TemporalAccessor!: the temporal object to convert, not null
Return
ChronoZonedDateTime<JapaneseDate!>! the zoned date-time in this chronology, not null
Exceptions
java.time.DateTimeException if unable to create the date-time

zonedDateTime

Added in API level 26
fun zonedDateTime(
    instant: Instant!,
    zone: ZoneId!
): ChronoZonedDateTime<JapaneseDate!>!
Parameters
instant Instant!: the instant to create the date-time from, not null
zone ZoneId!: the time-zone, not null
Return
ChronoZonedDateTime<JapaneseDate!>! the zoned date-time, not null
Exceptions
java.time.DateTimeException if the result exceeds the supported range

Properties

INSTANCE

Added in API level 26
static val INSTANCE: JapaneseChronology!

Singleton instance for Japanese chronology.