Package org.joda.time
Class PeriodType
java.lang.Object
org.joda.time.PeriodType
- All Implemented Interfaces:
Serializable
Controls a period implementation by specifying which duration fields are to be used.
The following implementations are provided:
- Standard - years, months, weeks, days, hours, minutes, seconds, millis
- YearMonthDayTime - years, months, days, hours, minutes, seconds, millis
- YearMonthDay - years, months, days
- YearWeekDayTime - years, weeks, days, hours, minutes, seconds, millis
- YearWeekDay - years, weeks, days
- YearDayTime - years, days, hours, minutes, seconds, millis
- YearDay - years, days, hours
- DayTime - days, hours, minutes, seconds, millis
- Time - hours, minutes, seconds, millis
- plus one for each single type
PeriodType is thread-safe and immutable, and all subclasses must be as well.
- Since:
- 1.0
- Author:
- Brian S O'Neill, Stephen Colebourne
- See Also:
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedPeriodType(String name, DurationFieldType[] types, int[] indices) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionstatic PeriodTypedays()Gets a type that defines just the days field.static PeriodTypedayTime()Gets a type that defines all standard fields from days downwards.booleanCompares this type to another object.static PeriodTypeforFields(DurationFieldType[] types) Gets a period type that contains the duration types of the array.getFieldType(int index) Gets the field type by index.getName()Gets the name of the period type.inthashCode()Returns a hashcode based on the field types.static PeriodTypehours()Gets a type that defines just the hours field.intindexOf(DurationFieldType type) Gets the index of the field in this period.booleanisSupported(DurationFieldType type) Checks whether the field specified is supported by this period.static PeriodTypemillis()Gets a type that defines just the millis field.static PeriodTypeminutes()Gets a type that defines just the minutes field.static PeriodTypemonths()Gets a type that defines just the months field.static PeriodTypeseconds()Gets a type that defines just the seconds field.intsize()Gets the number of fields in the period type.static PeriodTypestandard()Gets a type that defines all standard fields.static PeriodTypetime()Gets a type that defines all standard time fields.toString()Gets a debugging to string.static PeriodTypeweeks()Gets a type that defines just the weeks field.Returns a version of this PeriodType instance that does not support days.Returns a version of this PeriodType instance that does not support hours.Returns a version of this PeriodType instance that does not support milliseconds.Returns a version of this PeriodType instance that does not support minutes.Returns a version of this PeriodType instance that does not support months.Returns a version of this PeriodType instance that does not support seconds.Returns a version of this PeriodType instance that does not support weeks.Returns a version of this PeriodType instance that does not support years.static PeriodTypeyearDay()Gets a type that defines the year and day fields.static PeriodTypeGets a type that defines all standard fields except months and weeks.static PeriodTypeGets a type that defines the year, month and day fields.static PeriodTypeGets a type that defines all standard fields except weeks.static PeriodTypeyears()Gets a type that defines just the years field.static PeriodTypeGets a type that defines year, week and day fields.static PeriodTypeGets a type that defines all standard fields except months.
-
Constructor Details
-
PeriodType
Constructor.- Parameters:
name- the nametypes- the typesindices- the indices
-
-
Method Details
-
standard
Gets a type that defines all standard fields.- years
- months
- weeks
- days
- hours
- minutes
- seconds
- milliseconds
- Returns:
- the period type
-
yearMonthDayTime
Gets a type that defines all standard fields except weeks.- years
- months
- days
- hours
- minutes
- seconds
- milliseconds
- Returns:
- the period type
-
yearMonthDay
Gets a type that defines the year, month and day fields.- years
- months
- days
- Returns:
- the period type
- Since:
- 1.1
-
yearWeekDayTime
Gets a type that defines all standard fields except months.- years
- weeks
- days
- hours
- minutes
- seconds
- milliseconds
- Returns:
- the period type
-
yearWeekDay
Gets a type that defines year, week and day fields.- years
- weeks
- days
- Returns:
- the period type
- Since:
- 1.1
-
yearDayTime
Gets a type that defines all standard fields except months and weeks.- years
- days
- hours
- minutes
- seconds
- milliseconds
- Returns:
- the period type
-
yearDay
Gets a type that defines the year and day fields.- years
- days
- Returns:
- the period type
- Since:
- 1.1
-
dayTime
Gets a type that defines all standard fields from days downwards.- days
- hours
- minutes
- seconds
- milliseconds
- Returns:
- the period type
-
time
Gets a type that defines all standard time fields.- hours
- minutes
- seconds
- milliseconds
- Returns:
- the period type
-
years
Gets a type that defines just the years field.- Returns:
- the period type
-
months
Gets a type that defines just the months field.- Returns:
- the period type
-
weeks
Gets a type that defines just the weeks field.- Returns:
- the period type
-
days
Gets a type that defines just the days field.- Returns:
- the period type
-
hours
Gets a type that defines just the hours field.- Returns:
- the period type
-
minutes
Gets a type that defines just the minutes field.- Returns:
- the period type
-
seconds
Gets a type that defines just the seconds field.- Returns:
- the period type
-
millis
Gets a type that defines just the millis field.- Returns:
- the period type
-
forFields
Gets a period type that contains the duration types of the array.Only the 8 standard duration field types are supported.
- Parameters:
types- the types to include in the array.- Returns:
- the period type
- Since:
- 1.1
-
getName
Gets the name of the period type.- Returns:
- the name
-
size
public int size()Gets the number of fields in the period type.- Returns:
- the number of fields
-
getFieldType
Gets the field type by index.- Parameters:
index- the index to retrieve- Returns:
- the field type
- Throws:
IndexOutOfBoundsException- if the index is invalid
-
isSupported
Checks whether the field specified is supported by this period.- Parameters:
type- the type to check, may be null which returns false- Returns:
- true if the field is supported
-
indexOf
Gets the index of the field in this period.- Parameters:
type- the type to check, may be null which returns -1- Returns:
- the index of -1 if not supported
-
toString
Gets a debugging to string. -
withYearsRemoved
Returns a version of this PeriodType instance that does not support years.- Returns:
- a new period type that supports the original set of fields except years
-
withMonthsRemoved
Returns a version of this PeriodType instance that does not support months.- Returns:
- a new period type that supports the original set of fields except months
-
withWeeksRemoved
Returns a version of this PeriodType instance that does not support weeks.- Returns:
- a new period type that supports the original set of fields except weeks
-
withDaysRemoved
Returns a version of this PeriodType instance that does not support days.- Returns:
- a new period type that supports the original set of fields except days
-
withHoursRemoved
Returns a version of this PeriodType instance that does not support hours.- Returns:
- a new period type that supports the original set of fields except hours
-
withMinutesRemoved
Returns a version of this PeriodType instance that does not support minutes.- Returns:
- a new period type that supports the original set of fields except minutes
-
withSecondsRemoved
Returns a version of this PeriodType instance that does not support seconds.- Returns:
- a new period type that supports the original set of fields except seconds
-
withMillisRemoved
Returns a version of this PeriodType instance that does not support milliseconds.- Returns:
- a new period type that supports the original set of fields except milliseconds
-
equals
Compares this type to another object. To be equal, the object must be a PeriodType with the same set of fields. -
hashCode
public int hashCode()Returns a hashcode based on the field types.
-