Class AbstractPartialFieldProperty
- java.lang.Object
-
- org.joda.time.field.AbstractPartialFieldProperty
-
- Direct Known Subclasses:
MonthDay.Property
,Partial.Property
,TimeOfDay.Property
,YearMonth.Property
,YearMonthDay.Property
public abstract class AbstractPartialFieldProperty extends java.lang.Object
AbstractPartialFieldProperty is a base class for binding a ReadablePartial to a DateTimeField.It allows the date and time manipulation code to be field based yet still easy to use.
- Since:
- 1.0
-
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description int
compareTo(ReadableInstant instant)
Compare this field to the same field on another instant.int
compareTo(ReadablePartial partial)
Compare this field to the same field on another partial instant.boolean
equals(java.lang.Object object)
Compares this property to another.abstract int
get()
Gets the value of this property from the instant.java.lang.String
getAsShortText()
Gets the short textual value of this property from the instant as a string in the default locale.java.lang.String
getAsShortText(java.util.Locale locale)
Gets the short textual value of this property from the instant as a string in the specified locale.java.lang.String
getAsString()
Gets the value of this property from the instant as a string.java.lang.String
getAsText()
Gets the textual value of this property from the instant as a string in the default locale.java.lang.String
getAsText(java.util.Locale locale)
Gets the textual value of this property from the instant as a string in the specified locale.DurationField
getDurationField()
Returns the duration per unit value of this field.abstract DateTimeField
getField()
Gets the field being used.DateTimeFieldType
getFieldType()
Gets the field type being used.int
getMaximumShortTextLength(java.util.Locale locale)
Gets the maximum short text length for the field.int
getMaximumTextLength(java.util.Locale locale)
Gets the maximum text length for the field.int
getMaximumValue()
Gets the maximum value for this field given the current field values.int
getMaximumValueOverall()
Gets the maximum value for the field ignoring the current time.int
getMinimumValue()
Gets the minimum value for this field given the current field values.int
getMinimumValueOverall()
Gets the minimum value for the field ignoring the current time.java.lang.String
getName()
Gets the name of the field.DurationField
getRangeDurationField()
Returns the range duration of this field.int
hashCode()
Gets a suitable hashcode for the object.java.lang.String
toString()
Output a debugging string.
-
-
-
Method Detail
-
getField
public abstract DateTimeField getField()
Gets the field being used.- Returns:
- the field
-
getFieldType
public DateTimeFieldType getFieldType()
Gets the field type being used.- Returns:
- the field type
-
getName
public java.lang.String getName()
Gets the name of the field.- Returns:
- the field name
-
get
public abstract int get()
Gets the value of this property from the instant.For example, the following two lines of code are equivalent:
partial.getDayOfMonth(); partial.dayOfMonth().get();
- Returns:
- the current value
-
getAsString
public java.lang.String getAsString()
Gets the value of this property from the instant as a string.This method returns the value converted to a
String
usingInteger.toString
. This method does NOT return textual descriptions such as 'Monday' or 'January'. SeegetAsText()
andgetAsShortText()
for those.- Returns:
- the current value
- Since:
- 1.1
- See Also:
DateTimeField.get(long)
-
getAsText
public java.lang.String getAsText()
Gets the textual value of this property from the instant as a string in the default locale.This method returns the value converted to a
String
returning the appropriate textual description wherever possible. Thus, a day of week of 1 would return 'Monday' in English.- Returns:
- the current text value
- See Also:
DateTimeField.getAsText(long, java.util.Locale)
-
getAsText
public java.lang.String getAsText(java.util.Locale locale)
Gets the textual value of this property from the instant as a string in the specified locale.This method returns the value converted to a
String
returning the appropriate textual description wherever possible. Thus, a day of week of 1 would return 'Monday' in English.- Parameters:
locale
- locale to use for selecting a text symbol, null means default- Returns:
- the current text value
- See Also:
DateTimeField.getAsText(long, java.util.Locale)
-
getAsShortText
public java.lang.String getAsShortText()
Gets the short textual value of this property from the instant as a string in the default locale.This method returns the value converted to a
String
returning the appropriate textual description wherever possible. Thus, a day of week of 1 would return 'Mon' in English.- Returns:
- the current text value
- See Also:
DateTimeField.getAsShortText(long, java.util.Locale)
-
getAsShortText
public java.lang.String getAsShortText(java.util.Locale locale)
Gets the short textual value of this property from the instant as a string in the specified locale.This method returns the value converted to a
String
returning the appropriate textual description wherever possible. Thus, a day of week of 1 would return 'Mon' in English.- Parameters:
locale
- locale to use for selecting a text symbol, null means default- Returns:
- the current text value
- See Also:
DateTimeField.getAsShortText(long, java.util.Locale)
-
getDurationField
public DurationField getDurationField()
Returns the duration per unit value of this field. For example, if this field represents "hour of day", then the duration is an hour.- Returns:
- the duration of this field, or UnsupportedDurationField
-
getRangeDurationField
public DurationField getRangeDurationField()
Returns the range duration of this field. For example, if this field represents "hour of day", then the range duration is a day.- Returns:
- the range duration of this field, or null if field has no range
-
getMinimumValueOverall
public int getMinimumValueOverall()
Gets the minimum value for the field ignoring the current time.- Returns:
- the minimum value
- See Also:
DateTimeField.getMinimumValue()
-
getMinimumValue
public int getMinimumValue()
Gets the minimum value for this field given the current field values.- Returns:
- the minimum value
- See Also:
DateTimeField.getMinimumValue()
-
getMaximumValueOverall
public int getMaximumValueOverall()
Gets the maximum value for the field ignoring the current time.- Returns:
- the maximum value
- See Also:
DateTimeField.getMaximumValue()
-
getMaximumValue
public int getMaximumValue()
Gets the maximum value for this field given the current field values.- Returns:
- the maximum value
- See Also:
DateTimeField.getMaximumValue()
-
getMaximumTextLength
public int getMaximumTextLength(java.util.Locale locale)
Gets the maximum text length for the field.- Parameters:
locale
- optional locale to use for selecting a text symbol- Returns:
- the maximum length
- See Also:
DateTimeField.getMaximumTextLength(java.util.Locale)
-
getMaximumShortTextLength
public int getMaximumShortTextLength(java.util.Locale locale)
Gets the maximum short text length for the field.- Parameters:
locale
- optional locale to use for selecting a text symbol- Returns:
- the maximum length
- See Also:
DateTimeField.getMaximumShortTextLength(java.util.Locale)
-
compareTo
public int compareTo(ReadableInstant instant)
Compare this field to the same field on another instant.The comparison is based on the value of the same field type, irrespective of any difference in chronology. Thus, if this property represents the hourOfDay field, then the hourOfDay field of the other instant will be queried whether in the same chronology or not.
- Parameters:
instant
- the instant to compare to- Returns:
- negative value if this is less, 0 if equal, or positive value if greater
- Throws:
java.lang.IllegalArgumentException
- if the instant is null or the instant doesn't support the field of this property
-
compareTo
public int compareTo(ReadablePartial partial)
Compare this field to the same field on another partial instant.The comparison is based on the value of the same field type, irrespective of any difference in chronology. Thus, if this property represents the hourOfDay field, then the hourOfDay field of the other partial will be queried whether in the same chronology or not.
- Parameters:
partial
- the partial to compare to- Returns:
- negative value if this is less, 0 if equal, or positive value if greater
- Throws:
java.lang.IllegalArgumentException
- if the instant is nulljava.lang.IllegalArgumentException
- if the field of this property cannot be queried on the specified instant
-
equals
public boolean equals(java.lang.Object object)
Compares this property to another.- Overrides:
equals
in classjava.lang.Object
- Parameters:
object
- the object to compare to- Returns:
- true if equal
-
hashCode
public int hashCode()
Gets a suitable hashcode for the object.- Overrides:
hashCode
in classjava.lang.Object
- Returns:
- the hashcode
- Since:
- 1.3
-
toString
public java.lang.String toString()
Output a debugging string.- Overrides:
toString
in classjava.lang.Object
- Returns:
- debugging string
-
-