@CalendarType(value="julian") public final class JulianCalendar extends Calendrical<JulianCalendar.Unit,JulianCalendar> implements LocalizedPatternSupport
Represents the proleptic Julian calendar.
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.
Furthermore, all elements defined in EpochDays and CommonElements are supported.
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));
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"));
| Modifier and Type | Class and Description |
|---|---|
static class |
JulianCalendar.Unit
Defines some calendar units for the Julian calendar.
|
| Modifier and Type | Field and Description |
|---|---|
static ChronoElement<HistoricDate> |
DATE
Represents the Julian date.
|
static ChronoElement<Integer> |
DAY_OF_MONTH
Represents the Julian day of month.
|
static ChronoElement<Weekday> |
DAY_OF_WEEK
Represents the Julian day of week.
|
static ChronoElement<Integer> |
DAY_OF_YEAR
Represents the Julian day of year.
|
static ChronoElement<HistoricEra> |
ERA
Represents the Julian era.
|
static TextElement<Integer> |
MONTH_OF_YEAR
Represents the Julian month.
|
static OrdinalWeekdayElement<JulianCalendar> |
WEEKDAY_IN_MONTH
Element with the ordinal day-of-week within given calendar month.
|
static ChronoElement<Integer> |
YEAR_OF_ERA
Represents the Julian year.
|
| Modifier and Type | Method and Description |
|---|---|
GeneralTimestamp<JulianCalendar> |
at(PlainTime time)
Creates a new local timestamp with this date and given wall time.
|
GeneralTimestamp<JulianCalendar> |
atTime(int hour,
int minute)
Is equivalent to
at(PlainTime.of(hour, minute)). |
static TimeAxis<JulianCalendar.Unit,JulianCalendar> |
axis()
Returns the associated time axis.
|
boolean |
equals(Object obj)
Based on the epoch day number and the calendar system.
|
int |
getDayOfMonth()
Yields the Julian day of month.
|
Weekday |
getDayOfWeek()
Determines the day of week.
|
int |
getDayOfYear()
Yields the Julian day of year.
|
static Weekmodel |
getDefaultWeekmodel()
Obtains the standard week model of this calendar.
|
HistoricEra |
getEra()
Yields the Julian era.
|
Month |
getMonth()
Yields the Julian month.
|
int |
getYear()
Yields the Julian year within current era.
|
int |
hashCode()
Based on the epoch day number.
|
boolean |
isLeapYear()
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 |
lengthOfMonth()
Yields the length of current Julian month in days.
|
int |
lengthOfYear()
Yields the length of current Julian year in days.
|
static JulianCalendar |
nowInSystemTime()
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.
|
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, isBeforeOrEqualpublic static final ChronoElement<HistoricDate> DATE
Represents the Julian date.
This element is identical to ChronoHistory.PROLEPTIC_JULIAN.date().
@FormattableElement(format="G") public static final ChronoElement<HistoricEra> ERA
Represents the Julian era.
This element is identical to ChronoHistory.PROLEPTIC_JULIAN.era(). Valid values are
either HistoricEra.AD or HistoricEra.BC. However, the era cannot be changed
by the expression julianDate.with(ERA, historicEra).
@FormattableElement(format="y") public static final ChronoElement<Integer> YEAR_OF_ERA
Represents the Julian year.
This element is identical to ChronoHistory.PROLEPTIC_JULIAN.yearOfEra().
@FormattableElement(format="M", alt="L") public static final TextElement<Integer> MONTH_OF_YEAR
Represents the Julian month.
This element is identical to ChronoHistory.PROLEPTIC_JULIAN.month().
@FormattableElement(format="d") public static final ChronoElement<Integer> DAY_OF_MONTH
Represents the Julian day of month.
This element is identical to ChronoHistory.PROLEPTIC_JULIAN.dayOfMonth().
@FormattableElement(format="D") public static final ChronoElement<Integer> DAY_OF_YEAR
Represents the Julian day of year.
@FormattableElement(format="E") public static final ChronoElement<Weekday> 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.
@FormattableElement(format="F") public static final OrdinalWeekdayElement<JulianCalendar> WEEKDAY_IN_MONTH
Element with the ordinal day-of-week within given calendar month.
public static JulianCalendar of(HistoricEra era, int yearOfEra, int month, int dayOfMonth)
Creates a new instance of a Julian calendar date.
era - either HistoricEra.AD or HistoricEra.BCyearOfEra - year of era in range 1 until 999,999,999month - month (1-12)dayOfMonth - day of month (1-31)JulianCalendarIllegalArgumentException - in case of any inconsistenciespublic static JulianCalendar of(HistoricEra era, int yearOfEra, Month month, int dayOfMonth)
Creates a new instance of a Julian calendar date.
era - either HistoricEra.AD or HistoricEra.BCyearOfEra - year of era in range 1 until 999,999,999month - month (1-12)dayOfMonth - day of month (1-31)JulianCalendarIllegalArgumentException - in case of any inconsistenciespublic static JulianCalendar nowInSystemTime()
Obtains the current calendar date in system time.
Convenient short-cut for: SystemClock.inLocalView().now(JulianCalendar.axis()).
SystemClock.inLocalView(),
ZonalClock.now(net.time4j.engine.Chronology)public HistoricEra getEra()
Yields the Julian era.
HistoricEra.AD or HistoricEra.BCpublic int getYear()
Yields the Julian year within current era.
1 <= year <= 999,999,999)public Month getMonth()
Yields the Julian month.
public int getDayOfMonth()
Yields the Julian day of month.
public Weekday getDayOfWeek()
Determines the day of week.
public int getDayOfYear()
Yields the Julian day of year.
public int lengthOfMonth()
Yields the length of current Julian month in days.
public int lengthOfYear()
Yields the length of current Julian year in days.
public boolean isLeapYear()
Is the year of this date a leap year?
public static boolean isValid(HistoricEra 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(HistoricEra, int, int, int)public GeneralTimestamp<JulianCalendar> 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<JulianCalendar> 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<JulianCalendar.Unit,JulianCalendar>Chronology.getChronoType()public int hashCode()
CalendricalBased on the epoch day number.
hashCode in class Calendrical<JulianCalendar.Unit,JulianCalendar>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<JulianCalendar.Unit,JulianCalendar>public static Weekmodel getDefaultWeekmodel()
Obtains the standard week model of this calendar.
The Julian calendar usually starts on Sunday.
public static TimeAxis<JulianCalendar.Unit,JulianCalendar> axis()
Returns the associated time axis.
Copyright © 2014–2021. All rights reserved.