Class JulianCalendar
- All Implemented Interfaces:
Serializable
,Comparable<JulianCalendar>
,CalendarDate
,ChronoDisplay
,Temporal<CalendarDate>
,LocalizedPatternSupport
Represents the proleptic Julian calendar.
Introduction
It is de facto the ancestor of modern gregorian calendar but does not reflect any historic anomalies and applies its leap year rules even backwards into the far past. The main difference to gregorian calendar is the leap year rule which considers every year as leap year whose number is divisible by four.
Following elements which are declared as constants are registered by this class
Furthermore, all elements defined in EpochDays
and CommonElements
are supported.
Example of usage
ChronoFormatter<JulianCalendar> formatter = ChronoFormatter.ofPattern( "E, d.MMMM yyyy", PatternType.CLDR, Locale.ENGLISH, JulianCalendar.axis()); PlainDate today = SystemClock.inLocalView().today(); JulianCalendar julianDate = today.transform(JulianCalendar.class); System.out.println(formatter.format(julianDate));
Support for unicode ca-extensions
Locale locale = Locale.forLanguageTag("en-u-ca-julian"); ChronoFormatter<CalendarDate> f = ChronoFormatter.ofGenericCalendarStyle(DisplayMode.FULL, locale); assertThat( f.format(PlainDate.of(2017, 10, 1)), is("Sunday, September 18, 2017 AD"));
- Since:
- 3.15/4.12
- Author:
- Meno Hochschild
- See Also:
- Serialized Form
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Defines some calendar units for the Julian calendar. -
Field Summary
Modifier and TypeFieldDescriptionstatic ChronoElement<HistoricDate>
Represents the Julian date.static ChronoElement<Integer>
Represents the Julian day of month.static ChronoElement<Weekday>
Represents the Julian day of week.static ChronoElement<Integer>
Represents the Julian day of year.static ChronoElement<HistoricEra>
Represents the Julian era.static TextElement<Integer>
Represents the Julian month.static OrdinalWeekdayElement<JulianCalendar>
Element with the ordinal day-of-week within given calendar month.static ChronoElement<Integer>
Represents the Julian year. -
Method Summary
Modifier and TypeMethodDescriptionCreates a new local timestamp with this date and given wall time.atTime(int hour, int minute)
Is equivalent toat(PlainTime.of(hour, minute))
.static TimeAxis<JulianCalendar.Unit,JulianCalendar>
axis()
Returns the associated time axis.boolean
Based on the epoch day number and the calendar system.int
Yields the Julian day of month.Determines the day of week.int
Yields the Julian day of year.static Weekmodel
Obtains the standard week model of this calendar.getEra()
Yields the Julian era.getMonth()
Yields the Julian month.int
getYear()
Yields the Julian year within current era.int
hashCode()
Based on the epoch day number.boolean
Is the year of this date a leap year?static boolean
isValid(HistoricEra era, int yearOfEra, int month, int dayOfMonth)
Queries if given parameter values form a well defined calendar date.int
Yields the length of current Julian month in days.int
Yields the length of current Julian year in days.static JulianCalendar
Obtains the current calendar date in system time.static JulianCalendar
of(HistoricEra era, int yearOfEra, int month, int dayOfMonth)
Creates a new instance of a Julian calendar date.static JulianCalendar
of(HistoricEra era, int yearOfEra, Month month, int dayOfMonth)
Creates a new instance of a Julian calendar date.toString()
Provides a complete textual representation of the state of this time point.Methods inherited from class net.time4j.engine.Calendrical
compareTo, getDaysSinceEpochUTC, 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
-
DATE
Represents the Julian date.
This element is identical to
ChronoHistory.PROLEPTIC_JULIAN.date()
. -
ERA
Represents the Julian era.
This element is identical to
ChronoHistory.PROLEPTIC_JULIAN.era()
. Valid values are eitherHistoricEra.AD
orHistoricEra.BC
. However, the era cannot be changed by the expressionjulianDate.with(ERA, historicEra)
. -
YEAR_OF_ERA
Represents the Julian year.
This element is identical to
ChronoHistory.PROLEPTIC_JULIAN.yearOfEra()
. -
MONTH_OF_YEAR
Represents the Julian month.
This element is identical to
ChronoHistory.PROLEPTIC_JULIAN.month()
. -
DAY_OF_MONTH
Represents the Julian day of month.
This element is identical to
ChronoHistory.PROLEPTIC_JULIAN.dayOfMonth()
. -
DAY_OF_YEAR
Represents the Julian day of year.
-
DAY_OF_WEEK
Represents the Julian day of week.
If the day-of-week is set to a new value then Time4J handles the Julian calendar week as starting on Sunday which is close to historic use.
-
WEEKDAY_IN_MONTH
@FormattableElement(format="F") public static final OrdinalWeekdayElement<JulianCalendar> WEEKDAY_IN_MONTHElement with the ordinal day-of-week within given calendar month.
-
-
Method Details
-
of
Creates a new instance of a Julian calendar date.
- Parameters:
era
- eitherHistoricEra.AD
orHistoricEra.BC
yearOfEra
- year of era in range 1 until 999,999,999month
- month (1-12)dayOfMonth
- day of month (1-31)- Returns:
- new instance of
JulianCalendar
- Throws:
IllegalArgumentException
- in case of any inconsistencies- Since:
- 3.15/4.12
-
of
Creates a new instance of a Julian calendar date.
- Parameters:
era
- eitherHistoricEra.AD
orHistoricEra.BC
yearOfEra
- year of era in range 1 until 999,999,999month
- month (1-12)dayOfMonth
- day of month (1-31)- Returns:
- new instance of
JulianCalendar
- Throws:
IllegalArgumentException
- in case of any inconsistencies- Since:
- 3.15/4.12
-
nowInSystemTime
Obtains the current calendar date in system time.
Convenient short-cut for:
SystemClock.inLocalView().now(JulianCalendar.axis())
.- Returns:
- current calendar date in system time zone using the system clock
- Since:
- 3.23/4.19
- See Also:
SystemClock.inLocalView()
,ZonalClock.now(net.time4j.engine.Chronology)
-
getEra
Yields the Julian era.
- Returns:
- either
HistoricEra.AD
orHistoricEra.BC
- Since:
- 3.15/4.12
-
getYear
public int getYear()Yields the Julian year within current era.
- Returns:
- int (
1 <= year <= 999,999,999
) - Since:
- 3.15/4.12
-
getMonth
Yields the Julian month.
- Returns:
- enum
- Since:
- 3.15/4.12
-
getDayOfMonth
public int getDayOfMonth()Yields the Julian day of month.
- Returns:
- int
- Since:
- 3.15/4.12
-
getDayOfWeek
Determines the day of week.
- Returns:
- Weekday
- Since:
- 3.15/4.12
-
getDayOfYear
public int getDayOfYear()Yields the Julian day of year.
- Returns:
- int
- Since:
- 3.15/4.12
-
lengthOfMonth
public int lengthOfMonth()Yields the length of current Julian month in days.
- Returns:
- int
- Since:
- 3.15/4.12
-
lengthOfYear
public int lengthOfYear()Yields the length of current Julian year in days.
- Returns:
- int
- Since:
- 3.15/4.12
-
isLeapYear
public boolean isLeapYear()Is the year of this date a leap year?
- Returns:
- boolean
- Since:
- 3.15/4.12
-
isValid
Queries if given parameter values form a well defined calendar date.
- Parameters:
era
- the era to be checkedyearOfEra
- the year of era to be checkedmonth
- the month to be checkeddayOfMonth
- the day of month to be checked- Returns:
true
if valid elsefalse
- Since:
- 3.34/4.29
- See Also:
of(HistoricEra, int, int, int)
-
at
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.- Parameters:
time
- wall time- Returns:
- general timestamp as composition of this date and given time
- Since:
- 3.15/4.12
-
atTime
Is equivalent to
at(PlainTime.of(hour, minute))
.- Parameters:
hour
- hour of day in range (0-24)minute
- minute of hour in range (0-59)- Returns:
- general timestamp as composition of this date and given time
- Throws:
IllegalArgumentException
- if any argument is out of range- Since:
- 3.15/4.12
-
equals
Description copied from class:Calendrical
Based 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.- Overrides:
equals
in classCalendrical<JulianCalendar.Unit,JulianCalendar>
- See Also:
Chronology.getChronoType()
-
hashCode
public int hashCode()Description copied from class:Calendrical
Based on the epoch day number.
- Overrides:
hashCode
in classCalendrical<JulianCalendar.Unit,JulianCalendar>
-
toString
Description copied from class:TimePoint
Provides 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).
- Specified by:
toString
in classTimePoint<JulianCalendar.Unit,JulianCalendar>
-
getDefaultWeekmodel
Obtains the standard week model of this calendar.
The Julian calendar usually starts on Sunday.
- Returns:
- Weekmodel
- Since:
- 3.24/4.20
-
axis
Returns the associated time axis.
- Returns:
- chronology
- Since:
- 3.15/4.12
-