Package org.joda.time.chrono
Class JulianChronology
- java.lang.Object
-
- All Implemented Interfaces:
java.io.Serializable
public final class JulianChronology extends BasicGJChronology
Implements a pure proleptic Julian calendar system, which defines every fourth year as leap. This implementation follows the leap year rule strictly, even for dates before 8 CE, where leap years were actually irregular. In the Julian calendar, year zero does not exist: 1 BCE is followed by 1 CE.Although the Julian calendar did not exist before 45 BCE, this chronology assumes it did, thus it is proleptic. This implementation also fixes the start of the year at January 1.
JulianChronology is thread-safe and immutable.
- Since:
- 1.0
- See Also:
- Wikipedia,
GregorianChronology
,GJChronology
, Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.joda.time.chrono.AssembledChronology
AssembledChronology.Fields
-
-
Field Summary
Fields Modifier and Type Field Description private static java.util.concurrent.ConcurrentHashMap<DateTimeZone,JulianChronology[]>
cCache
Cache of zone to chronology arraysprivate static JulianChronology
INSTANCE_UTC
Singleton instance of a UTC JulianChronologyprivate static int
MAX_YEAR
The highest year that can be fully supported.private static long
MILLIS_PER_MONTH
private static long
MILLIS_PER_YEAR
private static int
MIN_YEAR
The lowest year that can be fully supported.private static long
serialVersionUID
Serialization lock
-
Constructor Summary
Constructors Constructor Description JulianChronology(Chronology base, java.lang.Object param, int minDaysInFirstWeek)
Restricted constructor
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) static int
adjustYearForSet(int year)
protected void
assemble(AssembledChronology.Fields fields)
Invoked by the constructor and after deserialization to allow subclasses to define all of its supported fields.(package private) long
calculateFirstDayOfYearMillis(int year)
Gets the millisecond value of the first day of the year.(package private) long
getApproxMillisAtEpochDividedByTwo()
Returns a constant representing the approximate number of milliseconds elapsed from year 0 of this chronology, divided by two.(package private) long
getAverageMillisPerMonth()
Gets an average value for the milliseconds per month.(package private) long
getAverageMillisPerYear()
Gets an average value for the milliseconds per year.(package private) long
getAverageMillisPerYearDividedByTwo()
Gets an average value for the milliseconds per year, divided by two.(package private) long
getDateMidnightMillis(int year, int monthOfYear, int dayOfMonth)
Gets the milliseconds for a date at midnight.static JulianChronology
getInstance()
Gets an instance of the JulianChronology in the default time zone.static JulianChronology
getInstance(DateTimeZone zone)
Gets an instance of the JulianChronology in the given time zone.static JulianChronology
getInstance(DateTimeZone zone, int minDaysInFirstWeek)
Gets an instance of the JulianChronology in the given time zone.static JulianChronology
getInstanceUTC()
Gets an instance of the JulianChronology.(package private) int
getMaxYear()
Gets the maximum supported year.(package private) int
getMinYear()
Gets the minimum supported year.(package private) boolean
isLeapYear(int year)
Is the specified year a leap year?private java.lang.Object
readResolve()
Serialization singletonChronology
withUTC()
Gets the Chronology in the UTC time zone.Chronology
withZone(DateTimeZone zone)
Gets the Chronology in a specific time zone.-
Methods inherited from class org.joda.time.chrono.BasicGJChronology
getDaysInMonthMax, getDaysInMonthMaxForSet, getDaysInYearMonth, getMonthOfYear, getTotalMillisByYearMonth, getYearDifference, isLeapDay, setYear
-
Methods inherited from class org.joda.time.chrono.BasicChronology
equals, getDateTimeMillis, getDateTimeMillis, getDayOfMonth, getDayOfMonth, getDayOfMonth, getDayOfWeek, getDayOfYear, getDayOfYear, getDaysInMonthMax, getDaysInMonthMax, getDaysInYear, getDaysInYearMax, getFirstWeekOfYearMillis, getMaxMonth, getMaxMonth, getMillisOfDay, getMinimumDaysInFirstWeek, getMonthOfYear, getWeekOfWeekyear, getWeekOfWeekyear, getWeeksInYear, getWeekyear, getYear, getYearMillis, getYearMonthDayMillis, getYearMonthMillis, getZone, hashCode, toString
-
Methods inherited from class org.joda.time.chrono.AssembledChronology
centuries, centuryOfEra, clockhourOfDay, clockhourOfHalfday, dayOfMonth, dayOfWeek, dayOfYear, days, era, eras, getBase, getDateTimeMillis, getParam, halfdayOfDay, halfdays, hourOfDay, hourOfHalfday, hours, millis, millisOfDay, millisOfSecond, minuteOfDay, minuteOfHour, minutes, monthOfYear, months, secondOfDay, secondOfMinute, seconds, weekOfWeekyear, weeks, weekyear, weekyearOfCentury, weekyears, year, yearOfCentury, yearOfEra, years
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
Serialization lock- See Also:
- Constant Field Values
-
MILLIS_PER_YEAR
private static final long MILLIS_PER_YEAR
- See Also:
- Constant Field Values
-
MILLIS_PER_MONTH
private static final long MILLIS_PER_MONTH
- See Also:
- Constant Field Values
-
MIN_YEAR
private static final int MIN_YEAR
The lowest year that can be fully supported.- See Also:
- Constant Field Values
-
MAX_YEAR
private static final int MAX_YEAR
The highest year that can be fully supported.- See Also:
- Constant Field Values
-
INSTANCE_UTC
private static final JulianChronology INSTANCE_UTC
Singleton instance of a UTC JulianChronology
-
cCache
private static final java.util.concurrent.ConcurrentHashMap<DateTimeZone,JulianChronology[]> cCache
Cache of zone to chronology arrays
-
-
Constructor Detail
-
JulianChronology
JulianChronology(Chronology base, java.lang.Object param, int minDaysInFirstWeek)
Restricted constructor
-
-
Method Detail
-
adjustYearForSet
static int adjustYearForSet(int year)
-
getInstanceUTC
public static JulianChronology getInstanceUTC()
Gets an instance of the JulianChronology. The time zone of the returned instance is UTC.- Returns:
- a singleton UTC instance of the chronology
-
getInstance
public static JulianChronology getInstance()
Gets an instance of the JulianChronology in the default time zone.- Returns:
- a chronology in the default time zone
-
getInstance
public static JulianChronology getInstance(DateTimeZone zone)
Gets an instance of the JulianChronology in the given time zone.- Parameters:
zone
- the time zone to get the chronology in, null is default- Returns:
- a chronology in the specified time zone
-
getInstance
public static JulianChronology getInstance(DateTimeZone zone, int minDaysInFirstWeek)
Gets an instance of the JulianChronology in the given time zone.- Parameters:
zone
- the time zone to get the chronology in, null is defaultminDaysInFirstWeek
- minimum number of days in first week of the year; default is 4- Returns:
- a chronology in the specified time zone
-
readResolve
private java.lang.Object readResolve()
Serialization singleton
-
withUTC
public Chronology withUTC()
Gets the Chronology in the UTC time zone.- Specified by:
withUTC
in classBaseChronology
- Returns:
- the chronology in UTC
-
withZone
public Chronology withZone(DateTimeZone zone)
Gets the Chronology in a specific time zone.- Specified by:
withZone
in classBaseChronology
- Parameters:
zone
- the zone to get the chronology in, null is default- Returns:
- the chronology
- See Also:
ZonedChronology
-
getDateMidnightMillis
long getDateMidnightMillis(int year, int monthOfYear, int dayOfMonth) throws java.lang.IllegalArgumentException
Description copied from class:BasicChronology
Gets the milliseconds for a date at midnight.- Overrides:
getDateMidnightMillis
in classBasicChronology
- Parameters:
year
- the yearmonthOfYear
- the monthdayOfMonth
- the day- Returns:
- the milliseconds
- Throws:
java.lang.IllegalArgumentException
-
isLeapYear
boolean isLeapYear(int year)
Description copied from class:BasicChronology
Is the specified year a leap year?- Specified by:
isLeapYear
in classBasicChronology
- Parameters:
year
- the year to test- Returns:
- true if leap
-
calculateFirstDayOfYearMillis
long calculateFirstDayOfYearMillis(int year)
Description copied from class:BasicChronology
Gets the millisecond value of the first day of the year.- Specified by:
calculateFirstDayOfYearMillis
in classBasicChronology
- Returns:
- the milliseconds for the first of the year
-
getMinYear
int getMinYear()
Description copied from class:BasicChronology
Gets the minimum supported year.- Specified by:
getMinYear
in classBasicChronology
- Returns:
- the year
-
getMaxYear
int getMaxYear()
Description copied from class:BasicChronology
Gets the maximum supported year.- Specified by:
getMaxYear
in classBasicChronology
- Returns:
- the year
-
getAverageMillisPerYear
long getAverageMillisPerYear()
Description copied from class:BasicChronology
Gets an average value for the milliseconds per year.- Specified by:
getAverageMillisPerYear
in classBasicChronology
- Returns:
- the millis per year
-
getAverageMillisPerYearDividedByTwo
long getAverageMillisPerYearDividedByTwo()
Description copied from class:BasicChronology
Gets an average value for the milliseconds per year, divided by two.- Specified by:
getAverageMillisPerYearDividedByTwo
in classBasicChronology
- Returns:
- the millis per year divided by two
-
getAverageMillisPerMonth
long getAverageMillisPerMonth()
Description copied from class:BasicChronology
Gets an average value for the milliseconds per month.- Specified by:
getAverageMillisPerMonth
in classBasicChronology
- Returns:
- the millis per month
-
getApproxMillisAtEpochDividedByTwo
long getApproxMillisAtEpochDividedByTwo()
Description copied from class:BasicChronology
Returns a constant representing the approximate number of milliseconds elapsed from year 0 of this chronology, divided by two. This constant must be defined as:(yearAtEpoch * averageMillisPerYear + millisOfYearAtEpoch) / 2
where epoch is 1970-01-01 (Gregorian).- Specified by:
getApproxMillisAtEpochDividedByTwo
in classBasicChronology
-
assemble
protected void assemble(AssembledChronology.Fields fields)
Description copied from class:AssembledChronology
Invoked by the constructor and after deserialization to allow subclasses to define all of its supported fields. All unset fields default to unsupported instances.- Overrides:
assemble
in classBasicChronology
- Parameters:
fields
- container of fields
-
-