/** * Returns a hashcode compatible with the equals method. * * @return the hashcode */ public int hashCode() { return get() * 17 + getFieldType().hashCode() + getChronology().hashCode(); }
/** * Gets the short textual value of this property from the instant as a * string in the default locale. * <p> * This method returns the value converted to a <code>String</code> * returning the appropriate textual description wherever possible. * Thus, a day of week of 1 would return 'Mon' in English. * * @return the current text value * @see DateTimeField#getAsShortText */ public String getAsShortText() { return getAsShortText(null); }
/** * Gets the textual value of this property from the instant as a * string in the default locale. * <p> * This method returns the value converted to a <code>String</code> * returning the appropriate textual description wherever possible. * Thus, a day of week of 1 would return 'Monday' in English. * * @return the current text value * @see DateTimeField#getAsText */ public String getAsText() { return getAsText(null); }
/** * Compare this field to the same field on another instant. * <p> * 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. * * @param instant the instant to compare to * @return negative value if this is less, 0 if equal, or positive value if greater * @throws IllegalArgumentException if the instant is null */ public int compareTo(ReadableInstant instant) { if (instant == null) { throw new IllegalArgumentException("The instant must not be null"); } int thisValue = get(); int otherValue = instant.get(getFieldType()); if (thisValue < otherValue) { return -1; } else if (thisValue > otherValue) { return 1; } else { return 0; } }
/** * Returns the interval that represents the range of the minimum * and maximum values of this field. * <p> * For example, <code>datetime.monthOfYear().toInterval()</code> * will return an interval over the whole month. * * @return the interval of this field * @since 1.2 */ public Interval toInterval() { DateTimeField field = getField(); long start = field.roundFloor(getMillis()); long end = field.add(start, 1); Interval interval = new Interval(start, end, getChronology()); return interval; }
/** * Gets the name of the field. * * @return the field name */ public String getName() { return getField().getName(); }
/** * Output a debugging string. * * @return debugging string */ public String toString() { return "Property[" + getName() + "]"; }
/** * Gets the value of this property from the instant as a string. * <p> * This method returns the value converted to a <code>String</code> * using <code>Integer.toString</code>. This method does NOT return * textual descriptions such as 'Monday' or 'January'. * See {@link #getAsText()} and {@link #getAsShortText()} for those. * * @return the current value * @see DateTimeField#get * @since 1.1 */ public String getAsString() { return Integer.toString(get()); }
/** * Returns the interval that represents the range of the minimum * and maximum values of this field. * <p> * For example, <code>datetime.monthOfYear().toInterval()</code> * will return an interval over the whole month. * * @return the interval of this field * @since 1.2 */ public Interval toInterval() { DateTimeField field = getField(); long start = field.roundFloor(getMillis()); long end = field.add(start, 1); Interval interval = new Interval(start, end, getChronology()); return interval; }
/** * Compare this field to the same field on another partial instant. * <p> * 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. * * @param partial the partial to compare to * @return negative value if this is less, 0 if equal, or positive value if greater * @throws IllegalArgumentException if the partial is null * @throws IllegalArgumentException if the partial doesn't support this field */ public int compareTo(ReadablePartial partial) { if (partial == null) { throw new IllegalArgumentException("The partial must not be null"); } int thisValue = get(); int otherValue = partial.get(getFieldType()); if (thisValue < otherValue) { return -1; } else if (thisValue > otherValue) { return 1; } else { return 0; } }
/** * If this field were to leap, then it would be in units described by the * returned duration. If this field doesn't ever leap, null is returned. */ public DurationField getLeapDurationField() { return getField().getLeapDurationField(); }
/** * Output a debugging string. * * @return debugging string */ public String toString() { return "Property[" + getName() + "]"; }
/** * Gets the value of this property from the instant as a string. * <p> * This method returns the value converted to a <code>String</code> * using <code>Integer.toString</code>. This method does NOT return * textual descriptions such as 'Monday' or 'January'. * See {@link #getAsText()} and {@link #getAsShortText()} for those. * * @return the current value * @see DateTimeField#get * @since 1.1 */ public String getAsString() { return Integer.toString(get()); }
/** * Returns a hashcode compatible with the equals method. * * @return the hashcode */ public int hashCode() { return get() * 17 + getFieldType().hashCode() + getChronology().hashCode(); }
/** * Returns the interval that represents the range of the minimum * and maximum values of this field. * <p> * For example, <code>datetime.monthOfYear().toInterval()</code> * will return an interval over the whole month. * * @return the interval of this field * @since 1.2 */ public Interval toInterval() { DateTimeField field = getField(); long start = field.roundFloor(getMillis()); long end = field.add(start, 1); Interval interval = new Interval(start, end, getChronology()); return interval; }
/** * Compare this field to the same field on another instant. * <p> * 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. * * @param instant the instant to compare to * @return negative value if this is less, 0 if equal, or positive value if greater * @throws IllegalArgumentException if the instant is null */ public int compareTo(ReadableInstant instant) { if (instant == null) { throw new IllegalArgumentException("The instant must not be null"); } int thisValue = get(); int otherValue = instant.get(getFieldType()); if (thisValue < otherValue) { return -1; } else if (thisValue > otherValue) { return 1; } else { return 0; } }
/** * Gets the minimum value for the field ignoring the current time. * * @return the minimum value * @see DateTimeField#getMinimumValue */ public int getMinimumValueOverall() { return getField().getMinimumValue(); }