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:
java.io.Serializable
- Direct Known Subclasses:
CopticChronology
,EthiopicChronology
abstract class BasicFixedMonthChronology extends BasicChronology
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
Fields Modifier and Type Field Description (package private) static long
MILLIS_PER_MONTH
The length of the month in millis.(package private) static long
MILLIS_PER_YEAR
The typical millis per year.(package private) static int
MONTH_LENGTH
The length of the month.private static long
serialVersionUID
Serialization lock
-
Constructor Summary
Constructors Constructor Description BasicFixedMonthChronology(Chronology base, java.lang.Object param, int minDaysInFirstWeek)
Restricted constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description (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) int
getDayOfMonth(long millis)
(package private) int
getDaysInMonthMax()
Gets the maximum number of days in any month.(package private) int
getDaysInMonthMax(int month)
Gets the maximum days in the specified month.(package private) int
getDaysInYearMonth(int year, int month)
Gets the number of days in the specified month and year.(package private) int
getMaxMonth()
Gets the maximum number of months.(package private) int
getMonthOfYear(long millis)
(package private) int
getMonthOfYear(long millis, int year)
(package private) long
getTotalMillisByYearMonth(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) long
getYearDifference(long minuendInstant, long subtrahendInstant)
Gets the difference between the two instants in years.(package private) boolean
isLeapYear(int year)
Is the specified year a leap year?(package private) long
setYear(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, 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
-
MONTH_LENGTH
static final int MONTH_LENGTH
The length of the month.- See Also:
- Constant Field Values
-
MILLIS_PER_YEAR
static final long MILLIS_PER_YEAR
The typical millis per year.- See Also:
- Constant Field Values
-
MILLIS_PER_MONTH
static final long MILLIS_PER_MONTH
The length of the month in millis.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
BasicFixedMonthChronology
BasicFixedMonthChronology(Chronology base, java.lang.Object param, int minDaysInFirstWeek)
Restricted constructor.- Parameters:
base
- the base chronologyparam
- the init parameterminDaysInFirstWeek
- the minimum days in the first week
-
-
Method Detail
-
setYear
long setYear(long instant, int year)
Description copied from class:BasicChronology
Sets the year from an instant and year.- Specified by:
setYear
in 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:BasicChronology
Gets the difference between the two instants in years.- Specified by:
getYearDifference
in classBasicChronology
- Parameters:
minuendInstant
- the first instantsubtrahendInstant
- the second instant- Returns:
- the difference
-
getTotalMillisByYearMonth
long getTotalMillisByYearMonth(int year, int month)
Description copied from class:BasicChronology
Gets the total number of millis elapsed in this year at the start of the specified month, such as zero for month 1.- Specified by:
getTotalMillisByYearMonth
in classBasicChronology
- Parameters:
year
- the yearmonth
- the month- Returns:
- the elapsed millis at the start of the month
-
getDayOfMonth
int getDayOfMonth(long millis)
- Overrides:
getDayOfMonth
in classBasicChronology
- Parameters:
millis
- from 1970-01-01T00:00:00Z
-
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
-
getDaysInYearMonth
int getDaysInYearMonth(int year, int month)
Description copied from class:BasicChronology
Gets the number of days in the specified month and year.- Specified by:
getDaysInYearMonth
in classBasicChronology
- Parameters:
year
- the yearmonth
- the month- Returns:
- the number of days
-
getDaysInMonthMax
int getDaysInMonthMax()
Description copied from class:BasicChronology
Gets the maximum number of days in any month.- Overrides:
getDaysInMonthMax
in classBasicChronology
- Returns:
- 31
-
getDaysInMonthMax
int getDaysInMonthMax(int month)
Description copied from class:BasicChronology
Gets the maximum days in the specified month.- Specified by:
getDaysInMonthMax
in classBasicChronology
- Parameters:
month
- the month- Returns:
- the max days
-
getMonthOfYear
int getMonthOfYear(long millis)
- Overrides:
getMonthOfYear
in classBasicChronology
- Parameters:
millis
- from 1970-01-01T00:00:00Z
-
getMonthOfYear
int getMonthOfYear(long millis, int year)
- Specified by:
getMonthOfYear
in classBasicChronology
- Parameters:
millis
- from 1970-01-01T00:00:00Zyear
- precalculated year of millis
-
getMaxMonth
int getMaxMonth()
Description copied from class:BasicChronology
Gets the maximum number of months.- Overrides:
getMaxMonth
in classBasicChronology
- Returns:
- 12
-
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
-
-