@CalendarType(value="buddhist") public final class ThaiSolarCalendar extends Calendrical<CalendarUnit,ThaiSolarCalendar> implements LocalizedPatternSupport
The Thai solar calendar calendar used in Thailand uses as only difference to western gregorian calendar a different year numbering with the Buddhist era mainly.
Furthermore, all elements defined in EpochDays and CommonElements are supported.

This class supports the calendar reform of 1940/41 after that the begin of year moved from 1st of April to 1st of January. See also: Wikipedia.
The date arithmetic uses the ISO-compatible class CalendarUnit and always delegate to
the ISO-equivalent PlainDate due to the fact that this calendar has always been a derivate
of the western gregorian calendar (years are intended as approximate solar years). However, if
applied on dates around the year 1940 where the begin of year was moved from 1st of April to 1st of
January users might observe some changes of buddhist year numbering which appear strange on first
glance. Example: ThaiSolarCalendar.ofBuddhist(2482, FEBRUARY, 1).plus(2, CalendarUnit.YEARS)
results in ThaiSolarCalendar.ofBuddhist(2485, FEBRUARY, 1). The addition of two (solar) years
corresponds to the addition of apparently three buddhist years in this edge case. If translated to
its ISO-equivalent the reason is clear: [1940-02-01] + 2 years = [1942-02-01].
Locale locale = Locale.forLanguageTag("en-u-ca-buddhist");
ChronoFormatter<CalendarDate> f = ChronoFormatter.ofGenericCalendarStyle(DisplayMode.FULL, locale);
assertThat(
f.format(PlainDate.of(2017, 10, 1)),
is("Sunday, October 1, 2560 BE"));
| Modifier and Type | Field and Description |
|---|---|
static StdCalendarElement<Integer,ThaiSolarCalendar> |
DAY_OF_MONTH
Represents the day of month.
|
static StdCalendarElement<Weekday,ThaiSolarCalendar> |
DAY_OF_WEEK
Represents the day of week.
|
static StdCalendarElement<Integer,ThaiSolarCalendar> |
DAY_OF_YEAR
Represents the day of year.
|
static ChronoElement<ThaiSolarEra> |
ERA
Represents the Thai era.
|
static StdCalendarElement<Month,ThaiSolarCalendar> |
MONTH_OF_YEAR
Represents the month.
|
static OrdinalWeekdayElement<ThaiSolarCalendar> |
WEEKDAY_IN_MONTH
Element with the ordinal day-of-week within given calendar month.
|
static StdCalendarElement<Integer,ThaiSolarCalendar> |
YEAR_OF_ERA
Represents the Thai year, usually in buddhist counting.
|
| Modifier and Type | Method and Description |
|---|---|
GeneralTimestamp<ThaiSolarCalendar> |
at(PlainTime time)
Creates a new local timestamp with this date and given wall time.
|
GeneralTimestamp<ThaiSolarCalendar> |
atTime(int hour,
int minute)
Is equivalent to
at(PlainTime.of(hour, minute)). |
static TimeAxis<CalendarUnit,ThaiSolarCalendar> |
axis()
Returns the associated time axis.
|
boolean |
equals(Object obj)
Based on the epoch day number and the calendar system.
|
int |
getDayOfMonth()
Yields the day of month.
|
Weekday |
getDayOfWeek()
Determines the day of week.
|
int |
getDayOfYear()
Yields the day of year.
|
static Weekmodel |
getDefaultWeekmodel()
Obtains the standard week model of this calendar.
|
ThaiSolarEra |
getEra()
Yields the buddhist era.
|
Month |
getMonth()
Yields the (gregorian) month.
|
int |
getYear()
Yields the buddhist Thai year.
|
int |
hashCode()
Based on the epoch day number.
|
boolean |
isLeapYear()
Is the year of this date a leap year?
|
static boolean |
isValid(ThaiSolarEra era,
int yearOfEra,
int month,
int dayOfMonth)
Queries if given parameter values form a well defined calendar date.
|
int |
lengthOfMonth()
Yields the length of current month in days.
|
int |
lengthOfYear()
Yields the length of current year in days.
|
static ThaiSolarCalendar |
nowInSystemTime()
Obtains the current calendar date in system time.
|
static ThaiSolarCalendar |
of(ThaiSolarEra era,
int yearOfEra,
int month,
int dayOfMonth)
Creates a new instance of a Thai solar calendar date.
|
static ThaiSolarCalendar |
ofBuddhist(int yearOfEra,
int month,
int dayOfMonth)
Creates a new instance of a Thai solar calendar date.
|
static ThaiSolarCalendar |
ofBuddhist(int yearOfEra,
Month month,
int dayOfMonth)
Creates a new instance of a Thai solar calendar date.
|
String |
toString()
Provides a complete textual representation of the state of
this time point.
|
compareTo, getDaysSinceEpochUTC, isAfter, isBefore, isSimultaneous, minus, plusmax, min, minus, minus, plus, plus, until, untilcontains, get, get, getInt, getMaximum, getMinimum, getRegisteredElements, getTimezone, hasTimezone, isValid, isValid, isValid, matches, with, with, with, withgetFormatPattern, getFormatPattern, useDynamicFormatPatternfrom, from, from, transform, transform, transform, transform, transform, transformisAfterAll, isAfterOrEqual, isBeforeAll, isBeforeOrEqual@FormattableElement(format="G") public static final ChronoElement<ThaiSolarEra> ERA
Represents the Thai era.
@FormattableElement(format="y") public static final StdCalendarElement<Integer,ThaiSolarCalendar> YEAR_OF_ERA
Represents the Thai year, usually in buddhist counting.
@FormattableElement(format="M", alt="L") public static final StdCalendarElement<Month,ThaiSolarCalendar> MONTH_OF_YEAR
Represents the month.
@FormattableElement(format="d") public static final StdCalendarElement<Integer,ThaiSolarCalendar> DAY_OF_MONTH
Represents the day of month.
@FormattableElement(format="D") public static final StdCalendarElement<Integer,ThaiSolarCalendar> DAY_OF_YEAR
Represents the day of year.
@FormattableElement(format="E") public static final StdCalendarElement<Weekday,ThaiSolarCalendar> DAY_OF_WEEK
Represents the day of week.
If the day-of-week is set to a new value then Time4J handles the calendar week as starting on Sunday.
@FormattableElement(format="F") public static final OrdinalWeekdayElement<ThaiSolarCalendar> WEEKDAY_IN_MONTH
Element with the ordinal day-of-week within given calendar month.
public static ThaiSolarCalendar ofBuddhist(int yearOfEra, Month month, int dayOfMonth)
Creates a new instance of a Thai solar calendar date.
yearOfEra - buddhist year of era >= 1month - gregorian monthdayOfMonth - day of monthThaiSolarCalendarIllegalArgumentException - in case of any inconsistenciespublic static ThaiSolarCalendar ofBuddhist(int yearOfEra, int month, int dayOfMonth)
Creates a new instance of a Thai solar calendar date.
yearOfEra - buddhist year of era >= 1month - gregorian month (1-12)dayOfMonth - day of monthThaiSolarCalendarIllegalArgumentException - in case of any inconsistenciespublic static ThaiSolarCalendar of(ThaiSolarEra era, int yearOfEra, int month, int dayOfMonth)
Creates a new instance of a Thai solar calendar date.
era - Thai erayearOfEra - Thai year of era >= 1month - gregorian month (1-12)dayOfMonth - day of monthThaiSolarCalendarIllegalArgumentException - in case of any inconsistenciespublic static ThaiSolarCalendar nowInSystemTime()
Obtains the current calendar date in system time.
Convenient short-cut for: SystemClock.inLocalView().now(ThaiSolarCalendar.axis()).
SystemClock.inLocalView(),
ZonalClock.now(net.time4j.engine.Chronology)public ThaiSolarEra getEra()
Yields the buddhist era.
ThaiSolarEra.BUDDHISTpublic int getYear()
Yields the buddhist Thai year.
ThaiSolarEra.BUDDHISTpublic Month getMonth()
Yields the (gregorian) month.
public int getDayOfMonth()
Yields the day of month.
public Weekday getDayOfWeek()
Determines the day of week.
public int getDayOfYear()
Yields the day of year.
public int lengthOfMonth()
Yields the length of current month in days.
public int lengthOfYear()
Yields the length of current year in days.
public boolean isLeapYear()
Is the year of this date a leap year?
public static boolean isValid(ThaiSolarEra era, int yearOfEra, int month, int dayOfMonth)
Queries if given parameter values form a well defined calendar date.
era - the era to be checkedyearOfEra - the year of era to be checkedmonth - the month to be checkeddayOfMonth - the day of month to be checkedtrue if valid else falseof(ThaiSolarEra, int, int, int)public GeneralTimestamp<ThaiSolarCalendar> at(PlainTime time)
Creates a new local timestamp with this date and given wall time.
If the time T24:00 is used
then the resulting timestamp will automatically be normalized such
that the timestamp will contain the following day instead.
time - wall timepublic GeneralTimestamp<ThaiSolarCalendar> atTime(int hour, int minute)
Is equivalent to at(PlainTime.of(hour, minute)).
hour - hour of day in range (0-24)minute - minute of hour in range (0-59)IllegalArgumentException - if any argument is out of rangepublic boolean equals(Object obj)
CalendricalBased on the epoch day number and the calendar system.
In other words: Two date object are equal if they have the same temporal position on the local timeline and have the same calendrical type. Subclasses which define further state attributes must override this method.
If an only temporal comparison is required then the method
Calendrical.isSimultaneous(CalendarDate) is to be used.
equals in class Calendrical<CalendarUnit,ThaiSolarCalendar>Chronology.getChronoType()public int hashCode()
CalendricalBased on the epoch day number.
hashCode in class Calendrical<CalendarUnit,ThaiSolarCalendar>public String toString()
TimePointProvides a complete textual representation of the state of this time point.
The textual description often follows the conventions of ISO-8601. Usually the description starts with the chronological informations which are coarse-grained and ends with those ones which are fine-grained (for example the ISO-notation YYYY-MM-DD).
toString in class TimePoint<CalendarUnit,ThaiSolarCalendar>public static Weekmodel getDefaultWeekmodel()
Obtains the standard week model of this calendar.
The thai calendar usually starts on Sunday.
public static TimeAxis<CalendarUnit,ThaiSolarCalendar> axis()
Returns the associated time axis.
Copyright © 2014–2021. All rights reserved.