Package org.joda.time.chrono
Class BasicFixedMonthChronology
java.lang.Object
org.joda.time.Chronology
org.joda.time.chrono.BaseChronology
org.joda.time.chrono.AssembledChronology
org.joda.time.chrono.BasicChronology
org.joda.time.chrono.BasicFixedMonthChronology
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
CopticChronology,EthiopicChronology
Abstract implementation of a calendar system based around fixed length months.
As the month length is fixed various calculations can be optimised. This implementation assumes any additional days after twelve months fall into a thirteenth month.
BasicFixedMonthChronology is thread-safe and immutable, and all subclasses must be as well.
- Since:
- 1.2, refactored from CopticChronology
-
Nested Class Summary
Nested classes/interfaces inherited from class org.joda.time.chrono.AssembledChronology
AssembledChronology.Fields -
Field Summary
FieldsModifier and TypeFieldDescription(package private) static final longThe length of the month in millis.(package private) static final longThe typical millis per year.(package private) static final intThe length of the month.private static final longSerialization lock -
Constructor Summary
ConstructorsConstructorDescriptionBasicFixedMonthChronology(Chronology base, Object param, int minDaysInFirstWeek) Restricted constructor. -
Method Summary
Modifier and TypeMethodDescription(package private) longGets an average value for the milliseconds per month.(package private) longGets an average value for the milliseconds per year.(package private) longGets an average value for the milliseconds per year, divided by two.(package private) intgetDayOfMonth(long millis) (package private) intGets the maximum number of days in any month.(package private) intgetDaysInMonthMax(int month) Gets the maximum days in the specified month.(package private) intgetDaysInYearMonth(int year, int month) Gets the number of days in the specified month and year.(package private) intGets the maximum number of months.(package private) intgetMonthOfYear(long millis) (package private) intgetMonthOfYear(long millis, int year) (package private) longgetTotalMillisByYearMonth(int year, int month) Gets the total number of millis elapsed in this year at the start of the specified month, such as zero for month 1.(package private) longgetYearDifference(long minuendInstant, long subtrahendInstant) Gets the difference between the two instants in years.(package private) booleanisLeapYear(int year) Is the specified year a leap year?(package private) longsetYear(long instant, int year) Sets the year from an instant and year.Methods inherited from class org.joda.time.chrono.BasicChronology
assemble, calculateFirstDayOfYearMillis, equals, getApproxMillisAtEpochDividedByTwo, getDateMidnightMillis, getDateTimeMillis, getDateTimeMillis, getDayOfMonth, getDayOfMonth, getDayOfWeek, getDayOfYear, getDayOfYear, getDaysInMonthMax, getDaysInMonthMaxForSet, getDaysInYear, getDaysInYearMax, getFirstWeekOfYearMillis, getMaxMonth, getMaxYear, getMillisOfDay, getMinimumDaysInFirstWeek, getMinYear, getWeekOfWeekyear, getWeekOfWeekyear, getWeeksInYear, getWeekyear, getYear, getYearMillis, getYearMonthDayMillis, getYearMonthMillis, getZone, hashCode, isLeapDay, toStringMethods 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 Details
-
serialVersionUID
private static final long serialVersionUIDSerialization lock- See Also:
-
MONTH_LENGTH
static final int MONTH_LENGTHThe length of the month.- See Also:
-
MILLIS_PER_YEAR
static final long MILLIS_PER_YEARThe typical millis per year.- See Also:
-
MILLIS_PER_MONTH
static final long MILLIS_PER_MONTHThe length of the month in millis.- See Also:
-
-
Constructor Details
-
BasicFixedMonthChronology
BasicFixedMonthChronology(Chronology base, Object param, int minDaysInFirstWeek) Restricted constructor.- Parameters:
base- the base chronologyparam- the init parameterminDaysInFirstWeek- the minimum days in the first week
-
-
Method Details
-
setYear
long setYear(long instant, int year) Description copied from class:BasicChronologySets the year from an instant and year.- Specified by:
setYearin classBasicChronology- Parameters:
instant- millis from 1970-01-01T00:00:00Zyear- the year to set- Returns:
- the updated millis
-
getYearDifference
long getYearDifference(long minuendInstant, long subtrahendInstant) Description copied from class:BasicChronologyGets the difference between the two instants in years.- Specified by:
getYearDifferencein classBasicChronology- Parameters:
minuendInstant- the first instantsubtrahendInstant- the second instant- Returns:
- the difference
-
getTotalMillisByYearMonth
long getTotalMillisByYearMonth(int year, int month) Description copied from class:BasicChronologyGets the total number of millis elapsed in this year at the start of the specified month, such as zero for month 1.- Specified by:
getTotalMillisByYearMonthin classBasicChronology- Parameters:
year- the yearmonth- the month- Returns:
- the elapsed millis at the start of the month
-
getDayOfMonth
int getDayOfMonth(long millis) - Overrides:
getDayOfMonthin classBasicChronology- Parameters:
millis- from 1970-01-01T00:00:00Z
-
isLeapYear
boolean isLeapYear(int year) Description copied from class:BasicChronologyIs the specified year a leap year?- Specified by:
isLeapYearin classBasicChronology- Parameters:
year- the year to test- Returns:
- true if leap
-
getDaysInYearMonth
int getDaysInYearMonth(int year, int month) Description copied from class:BasicChronologyGets the number of days in the specified month and year.- Specified by:
getDaysInYearMonthin classBasicChronology- Parameters:
year- the yearmonth- the month- Returns:
- the number of days
-
getDaysInMonthMax
int getDaysInMonthMax()Description copied from class:BasicChronologyGets the maximum number of days in any month.- Overrides:
getDaysInMonthMaxin classBasicChronology- Returns:
- 31
-
getDaysInMonthMax
int getDaysInMonthMax(int month) Description copied from class:BasicChronologyGets the maximum days in the specified month.- Specified by:
getDaysInMonthMaxin classBasicChronology- Parameters:
month- the month- Returns:
- the max days
-
getMonthOfYear
int getMonthOfYear(long millis) - Overrides:
getMonthOfYearin classBasicChronology- Parameters:
millis- from 1970-01-01T00:00:00Z
-
getMonthOfYear
int getMonthOfYear(long millis, int year) - Specified by:
getMonthOfYearin classBasicChronology- Parameters:
millis- from 1970-01-01T00:00:00Zyear- precalculated year of millis
-
getMaxMonth
int getMaxMonth()Description copied from class:BasicChronologyGets the maximum number of months.- Overrides:
getMaxMonthin classBasicChronology- Returns:
- 12
-
getAverageMillisPerYear
long getAverageMillisPerYear()Description copied from class:BasicChronologyGets an average value for the milliseconds per year.- Specified by:
getAverageMillisPerYearin classBasicChronology- Returns:
- the millis per year
-
getAverageMillisPerYearDividedByTwo
long getAverageMillisPerYearDividedByTwo()Description copied from class:BasicChronologyGets an average value for the milliseconds per year, divided by two.- Specified by:
getAverageMillisPerYearDividedByTwoin classBasicChronology- Returns:
- the millis per year divided by two
-
getAverageMillisPerMonth
long getAverageMillisPerMonth()Description copied from class:BasicChronologyGets an average value for the milliseconds per month.- Specified by:
getAverageMillisPerMonthin classBasicChronology- Returns:
- the millis per month
-