Class KoreanCalendar
- All Implemented Interfaces:
Serializable
,Comparable<KoreanCalendar>
,CalendarDate
,ChronoDisplay
,Temporal<CalendarDate>
,LocalizedPatternSupport
Represents the traditional Koran calendar supported in the gregorian range 1645-01-28/3000-01-27.
Introduction
It is a lunisolar calendar which defines years consisting of 12 or 13 months. See also Wikipedia.
Following elements which are declared as constants are registered by this class
DAY_OF_WEEK
DAY_OF_MONTH
DAY_OF_YEAR
WEEKDAY_IN_MONTH
MONTH_OF_YEAR
MONTH_AS_ORDINAL
SOLAR_TERM
YEAR_OF_CYCLE
YEAR_OF_ERA
CYCLE
ERA
Furthermore, all elements defined in KoreanEra
, EpochDays
and CommonElements
are supported.
Example of usage
ChronoFormatter<KoreanCalendar> formatter = ChronoFormatter.setUp(KoreanCalendar.axis(), Locale.ENGLISH) .addPattern("EEE, d. MMMM U(r)", PatternType.CLDR_DATE).build(); PlainDate today = SystemClock.inLocalView().today(); KoreanCalendar koreanDate = today.transform(KoreanCalendar.class); System.out.println(formatter.format(koreanDate));
Support for unicode ca-extensions
Locale locale = Locale.forLanguageTag("en-u-ca-dangi"); ChronoFormatter<CalendarDate> f = ChronoFormatter.ofGenericCalendarStyle(DisplayMode.FULL, locale); assertThat( f.format(PlainDate.of(2017, 10, 1)), is("Sunday, Eighth Month 12, 2017(dīng-yǒu)"));
- Since:
- 3.40/4.35
- Author:
- Meno Hochschild
- See Also:
ChineseCalendar
, Serialized Form
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Defines some calendar units for the Korean calendar. -
Field Summary
Modifier and TypeFieldDescriptionstatic ChronoElement<Integer>
Represents the cycle number related to the introduction of sexagesimal cycles by the legendary yellow emperor Huang-Di on -2636-02-15 (gregorian).static StdCalendarElement<Integer,KoreanCalendar>
Represents the Korean day of month.static StdCalendarElement<Weekday,KoreanCalendar>
Represents the Korean day of week.static StdCalendarElement<Integer,KoreanCalendar>
Represents the Korean day of year.static ChronoElement<KoreanEra>
Represents the Korean era.static StdCalendarElement<Integer,KoreanCalendar>
Represents the ordinal index of a Korean month in the range1-12/13
.static TextElement<EastAsianMonth>
Represents the Korean month.static ChronoElement<SolarTerm>
Represents the solar term as one of 24 possible stations of the sun on the ecliptic.static OrdinalWeekdayElement<KoreanCalendar>
Element with the ordinal day-of-week within given calendar month.static TextElement<CyclicYear>
Represents the Korean year related to the current sexagesimal cycle.static ChronoElement<Integer>
Represents the Korean year related to the Korean era. -
Method Summary
Modifier and TypeMethodDescriptionstatic TimeAxis<KoreanCalendar.Unit,KoreanCalendar>
axis()
Returns the associated time axis.static Weekmodel
Obtains the standard week model of this calendar.static boolean
isValid(EastAsianYear year, EastAsianMonth month, int dayOfMonth)
Queries if given parameter values form a well defined calendar date.static KoreanCalendar
Obtains the current calendar date in system time.static KoreanCalendar
of(EastAsianYear year, EastAsianMonth month, int dayOfMonth)
Creates a new instance of a Korean calendar date.static KoreanCalendar
ofNewYear(int gregorianYear)
Creates a new instance of a Korean calendar date on traditional New Year.Methods inherited from class net.time4j.calendar.EastAsianCalendar
at, atTime, equals, findLeapMonth, getDayOfMonth, getDayOfWeek, getDayOfYear, getDaysSinceEpochUTC, getMonth, getSexagesimalDay, getSexagesimalMonth, getSolarTerm, getYear, hashCode, isLeapYear, lengthOfMonth, lengthOfYear, toString, withBeginOfNextLeapMonth
Methods inherited from class net.time4j.engine.Calendrical
compareTo, isAfter, isBefore, isSimultaneous, minus, plus
Methods inherited from class net.time4j.engine.TimePoint
max, min, minus, minus, plus, plus, until, until
Methods inherited from class net.time4j.engine.ChronoEntity
contains, get, get, getInt, getMaximum, getMinimum, getRegisteredElements, getTimezone, hasTimezone, isValid, isValid, isValid, matches, with, with, with, with
Methods inherited from interface net.time4j.engine.CalendarDate
transform, transform, transform, transform, transform, transform
Methods inherited from interface net.time4j.format.LocalizedPatternSupport
getFormatPattern, getFormatPattern, useDynamicFormatPattern
Methods inherited from interface net.time4j.engine.Temporal
isAfterAll, isAfterOrEqual, isBeforeAll, isBeforeOrEqual
-
Field Details
-
ERA
Represents the Korean era.
This element is effectively read-only. Its value cannot be changed in a direct and meaningful way. The dangi era can also be used in conjunction with
PlainDate
.- See Also:
YEAR_OF_ERA
-
CYCLE
Represents the cycle number related to the introduction of sexagesimal cycles by the legendary yellow emperor Huang-Di on -2636-02-15 (gregorian).
This kind of counting is NOT in common use in Korea and only offered for technical reasons. Prefer just the cyclic year together with the related gregorian year instead.
-
YEAR_OF_ERA
Represents the Korean year related to the Korean era.
This kind of year counting is NOT in common use in Korea today and only offered for historical reasons. Prefer the cyclic year instead. The dangi era can also be used in conjunction with
PlainDate
. It was in use in South Korea from 1952 until 1961:ChronoFormatter<PlainDate> f = ChronoFormatter.setUp(PlainDate.axis(), Locale.ENGLISH) .addText(KoreanEra.DANGI.era()) .addLiteral(" ") .addInteger(KoreanEra.DANGI.yearOfEra(), 1, 4) .addPattern(", MM/dd", PatternType.CLDR) .build(); assertThat( f.format(PlainDate.of(2018, 10, 1)), is("Dangi 4351, 10/01")); assertThat( f.parse("Dangi 4351, 10/01"), is(PlainDate.of(2018, 10, 1)));
- See Also:
ERA
,YEAR_OF_CYCLE
-
YEAR_OF_CYCLE
Represents the Korean year related to the current sexagesimal cycle.
This is the standard way to specify a Korean year.
-
SOLAR_TERM
Represents the solar term as one of 24 possible stations of the sun on the ecliptic.
- See Also:
ChineseCalendar.SOLAR_TERM
-
MONTH_OF_YEAR
@FormattableElement(format="M", alt="L") public static final TextElement<EastAsianMonth> MONTH_OF_YEARRepresents the Korean month.
-
MONTH_AS_ORDINAL
Represents the ordinal index of a Korean month in the range
1-12/13
.This element can be used in conjunction with
ordinal formatting
. -
DAY_OF_MONTH
@FormattableElement(format="d") public static final StdCalendarElement<Integer,KoreanCalendar> DAY_OF_MONTHRepresents the Korean day of month.
Months have either 29 or 30 days.
-
DAY_OF_YEAR
@FormattableElement(format="D") public static final StdCalendarElement<Integer,KoreanCalendar> DAY_OF_YEARRepresents the Korean day of year.
-
DAY_OF_WEEK
@FormattableElement(format="E") public static final StdCalendarElement<Weekday,KoreanCalendar> DAY_OF_WEEKRepresents the Korean day of week.
If the day-of-week is set to a new value then Time4J handles the Korean calendar week as starting on Sunday (like in South-Korea).
-
WEEKDAY_IN_MONTH
@FormattableElement(format="F") public static final OrdinalWeekdayElement<KoreanCalendar> WEEKDAY_IN_MONTHElement with the ordinal day-of-week within given calendar month.
-
-
Method Details
-
ofNewYear
Creates a new instance of a Korean calendar date on traditional New Year.
- Parameters:
gregorianYear
- gregorian calendar year- Returns:
- new instance of
KoreanCalendar
- Throws:
IllegalArgumentException
- in case of any inconsistencies
-
of
Creates a new instance of a Korean calendar date.
- Parameters:
year
- references the year using different systems like eras or sexagesimal cyclesmonth
- the month which might be a leap monthdayOfMonth
- the day of month to be checked- Returns:
- new instance of
KoreanCalendar
- Throws:
IllegalArgumentException
- in case of any inconsistencies
-
nowInSystemTime
Obtains the current calendar date in system time.
Convenient short-cut for:
SystemClock.inLocalView().now(KoreanCalendar.axis())
.- Returns:
- current calendar date in system time zone using the system clock
- See Also:
SystemClock.inLocalView()
,ZonalClock.now(Chronology)
-
isValid
Queries if given parameter values form a well defined calendar date.
- Parameters:
year
- the year to be checkedmonth
- the month to be checkeddayOfMonth
- the day of month to be checked- Returns:
true
if valid elsefalse
-
getDefaultWeekmodel
Obtains the standard week model of this calendar.
The Korean calendar usually starts on Sunday (in South Korea).
- Returns:
- Weekmodel
-
axis
Returns the associated time axis.
- Returns:
- chronology
-