Class VietnameseCalendar
- All Implemented Interfaces:
Serializable,Comparable<VietnameseCalendar>,CalendarDate,ChronoDisplay,Temporal<CalendarDate>,LocalizedPatternSupport
Represents the Vietnamese calendar supported in the gregorian range 1813-02-01/3000-01-27.
Introduction
It is a lunisolar calendar which is supposed to be structurally identical to the Chinese calendar. See also the page of Ho Ngoc Duc. The historic details of the calendar rules before 1954 are somehow debatable. Probably different authorities or institutions in Vietnam used slightly different versions of Chinese calendar. Time4J follows the rules described on Wikipedia.
- 1813–1840: It was essentially the Shíxiàn calendar introduced by the Chinese Qing dynasty to the Vietnamese Nguyễn dynasty.
- 1841-1954: Hiệp-kỷ-calendar began to differ from Shíxiàn due to longitudinal differences between Vietnam and China.
- 1955-1967: UTC+8 is used for calendar calculations.
- since 1968: UTC+7 is used (first in North Vietnam, since reunification in 1975 also in Southern part).
Following elements which are declared as constants are registered by this class
DAY_OF_WEEKDAY_OF_MONTHDAY_OF_YEARWEEKDAY_IN_MONTHMONTH_OF_YEARMONTH_AS_ORDINALSOLAR_TERMYEAR_OF_CYCLECYCLE
Furthermore, all elements defined in EpochDays and CommonElements are supported.
Example of usage
ChronoFormatter<VietnameseCalendar> formatter =
ChronoFormatter.setUp(VietnameseCalendar.axis(), Locale.ENGLISH)
.addPattern("EEE, d. MMMM U(r)", PatternType.CLDR_DATE).build();
PlainDate today = SystemClock.inLocalView().today();
VietnameseCalendar vietDate = today.transform(VietnameseCalendar.class);
System.out.println(formatter.format(vietDate));
Support for unicode ca-extensions
Locale locale = Locale.forLanguageTag("en-u-ca-vietnam");
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
Nested ClassesModifier and TypeClassDescriptionstatic classDefines some calendar units for the Vietnamese calendar. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic ChronoElement<Integer>Represents the cycle number related to the introduction of sexagesimal cycles by the legendary Chinese yellow emperor Huang-Di on -2636-02-15 (gregorian).static StdCalendarElement<Integer,VietnameseCalendar>Represents the Vietnamese day of month.static StdCalendarElement<Weekday,VietnameseCalendar>Represents the Vietnamese day of week.static StdCalendarElement<Integer,VietnameseCalendar>Represents the Vietnamese day of year.static StdCalendarElement<Integer,VietnameseCalendar>Represents the ordinal index of a Vietnamese month in the range1-12/13.static TextElement<EastAsianMonth>Represents the Vietnamese month.static ChronoElement<SolarTerm>Represents the solar term as one of 24 possible stations of the sun on the ecliptic.Element with the ordinal day-of-week within given calendar month.static TextElement<CyclicYear>Represents the Vietnamese year related to the current sexagesimal cycle. -
Method Summary
Modifier and TypeMethodDescriptionaxis()Returns the associated time axis.static WeekmodelObtains the standard week model of this calendar.static booleanisValid(EastAsianYear year, EastAsianMonth month, int dayOfMonth)Queries if given parameter values form a well defined calendar date.static VietnameseCalendarObtains the current calendar date in system time.static VietnameseCalendarof(EastAsianYear year, EastAsianMonth month, int dayOfMonth)Creates a new instance of a Vietnamese calendar date.static VietnameseCalendarofTet(int gregorianYear)Creates a new instance of a Vietnamese calendar date on New Year (Tet).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, withBeginOfNextLeapMonthMethods inherited from class net.time4j.engine.Calendrical
compareTo, isAfter, isBefore, isSimultaneous, minus, plusMethods inherited from class net.time4j.engine.TimePoint
max, min, minus, minus, plus, plus, until, untilMethods inherited from class net.time4j.engine.ChronoEntity
contains, get, get, getInt, getMaximum, getMinimum, getRegisteredElements, getTimezone, hasTimezone, isValid, isValid, isValid, matches, with, with, with, withMethods inherited from interface net.time4j.engine.CalendarDate
transform, transform, transform, transform, transform, transformMethods inherited from interface net.time4j.format.LocalizedPatternSupport
getFormatPattern, getFormatPattern, useDynamicFormatPatternMethods inherited from interface net.time4j.engine.Temporal
isAfterAll, isAfterOrEqual, isBeforeAll, isBeforeOrEqual
-
Field Details
-
CYCLE
Represents the cycle number related to the introduction of sexagesimal cycles by the legendary Chinese yellow emperor Huang-Di on -2636-02-15 (gregorian).
This kind of counting is NOT in common use in Vietnam and only offered for technical reasons. Prefer just the cyclic year together with the related gregorian year instead.
-
YEAR_OF_CYCLE
Represents the Vietnamese year related to the current sexagesimal cycle.
-
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 Vietnamese month.
-
MONTH_AS_ORDINAL
Represents the ordinal index of a Vietnamese 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,VietnameseCalendar> DAY_OF_MONTHRepresents the Vietnamese day of month.
Months have either 29 or 30 days.
-
DAY_OF_YEAR
@FormattableElement(format="D") public static final StdCalendarElement<Integer,VietnameseCalendar> DAY_OF_YEARRepresents the Vietnamese day of year.
-
DAY_OF_WEEK
@FormattableElement(format="E") public static final StdCalendarElement<Weekday,VietnameseCalendar> DAY_OF_WEEKRepresents the Vietnamese day of week.
If the day-of-week is set to a new value then Time4J handles the Chinese calendar week as starting on Monday (like in modern Vietnam).
-
WEEKDAY_IN_MONTH
@FormattableElement(format="F") public static final OrdinalWeekdayElement<VietnameseCalendar> WEEKDAY_IN_MONTHElement with the ordinal day-of-week within given calendar month.
-
-
Method Details
-
ofTet
Creates a new instance of a Vietnamese calendar date on New Year (Tet).
- Parameters:
gregorianYear- gregorian calendar year- Returns:
- new instance of
VietnameseCalendar - Throws:
IllegalArgumentException- in case of any inconsistencies
-
of
Creates a new instance of a Vietnamese calendar date.
- Parameters:
year- references the year using sexagesimal cyclesmonth- the month which might be a leap monthdayOfMonth- the day of month to be checked- Returns:
- new instance of
ChineseCalendar - Throws:
IllegalArgumentException- in case of any inconsistencies
-
nowInSystemTime
Obtains the current calendar date in system time.
Convenient short-cut for:
SystemClock.inLocalView().now(VietnameseCalendar.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:
trueif valid elsefalse
-
getDefaultWeekmodel
Obtains the standard week model of this calendar.
The modern Vietnamese calendar usually starts on Monday.
- Returns:
- Weekmodel
-
axis
Returns the associated time axis.
- Returns:
- chronology
-