/** * Gets a hash code for the period as defined by ReadablePeriod. * * @return a hash code */ public int hashCode() { int total = 17; for (int i = 0, isize = size(); i < isize; i++) { total = 27 * total + getValue(i); total = 27 * total + getFieldType(i).hashCode(); } return total; }
/** * Gets the number of fields that this period supports. * * @return the number of fields supported * @since 2.0 (previously on BasePeriod) */ public int size() { return getPeriodType().size(); }
/** * Gets the value of one of the fields. * <p> * If the field type specified is not supported by the period then zero * is returned. * * @param type the field type to query, null returns zero * @return the value of that field, zero if field not supported */ public int get(DurationFieldType type) { int index = indexOf(type); if (index == -1) { return 0; } return getValue(index); }
/** * Gets an array of the field types that this period supports. * <p> * The fields are returned largest to smallest, for example Hours, Minutes, Seconds. * * @return the fields supported in an array that may be altered, largest to smallest */ public DurationFieldType[] getFieldTypes() { DurationFieldType[] result = new DurationFieldType[size()]; for (int i = 0; i < result.length; i++) { result[i] = getFieldType(i); } return result; }
/** * Gets an array of the value of each of the fields that this period supports. * <p> * The fields are returned largest to smallest, for example Hours, Minutes, Seconds. * Each value corresponds to the same array index as <code>getFields()</code> * * @return the current values of each field in an array that may be altered, largest to smallest */ public int[] getValues() { int[] result = new int[size()]; for (int i = 0; i < result.length; i++) { result[i] = getValue(i); } return result; }
/** * Uses the specified formatter to convert this period to a String. * * @param formatter the formatter to use, null means use <code>toString()</code>. * @return the formatted string * @since 1.5 */ public String toString(PeriodFormatter formatter) { if (formatter == null) { return toString(); } return formatter.print(this); }
/** * Gets an array of the field types that this period supports. * <p> * The fields are returned largest to smallest, for example Hours, Minutes, Seconds. * * @return the fields supported in an array that may be altered, largest to smallest */ public DurationFieldType[] getFieldTypes() { DurationFieldType[] result = new DurationFieldType[size()]; for (int i = 0; i < result.length; i++) { result[i] = getFieldType(i); } return result; }
/** * Gets an array of the value of each of the fields that this period supports. * <p> * The fields are returned largest to smallest, for example Hours, Minutes, Seconds. * Each value corresponds to the same array index as <code>getFields()</code> * * @return the current values of each field in an array that may be altered, largest to smallest */ public int[] getValues() { int[] result = new int[size()]; for (int i = 0; i < result.length; i++) { result[i] = getValue(i); } return result; }
/** * Uses the specified formatter to convert this period to a String. * * @param formatter the formatter to use, null means use <code>toString()</code>. * @return the formatted string * @since 1.5 */ public String toString(PeriodFormatter formatter) { if (formatter == null) { return toString(); } return formatter.print(this); }
/** * Gets a hash code for the period as defined by ReadablePeriod. * * @return a hash code */ public int hashCode() { int total = 17; for (int i = 0, isize = size(); i < isize; i++) { total = 27 * total + getValue(i); total = 27 * total + getFieldType(i).hashCode(); } return total; }
/** * Gets an array of the field types that this period supports. * <p> * The fields are returned largest to smallest, for example Hours, Minutes, Seconds. * * @return the fields supported in an array that may be altered, largest to smallest */ public DurationFieldType[] getFieldTypes() { DurationFieldType[] result = new DurationFieldType[size()]; for (int i = 0; i < result.length; i++) { result[i] = getFieldType(i); } return result; }
/** * Gets an array of the value of each of the fields that this period supports. * <p> * The fields are returned largest to smallest, for example Hours, Minutes, Seconds. * Each value corresponds to the same array index as <code>getFields()</code> * * @return the current values of each field in an array that may be altered, largest to smallest */ public int[] getValues() { int[] result = new int[size()]; for (int i = 0; i < result.length; i++) { result[i] = getValue(i); } return result; }
/** * Gets the value of one of the fields. * <p> * If the field type specified is not supported by the period then zero * is returned. * * @param type the field type to query, null returns zero * @return the value of that field, zero if field not supported */ public int get(DurationFieldType type) { int index = indexOf(type); if (index == -1) { return 0; } return getValue(index); }
/** * Gets the field type at the specified index. * * @param index the index to retrieve * @return the field at the specified index * @throws IndexOutOfBoundsException if the index is invalid * @since 2.0 (previously on BasePeriod) */ public DurationFieldType getFieldType(int index) { return getPeriodType().getFieldType(index); }
/** * Uses the specified formatter to convert this period to a String. * * @param formatter the formatter to use, null means use <code>toString()</code>. * @return the formatted string * @since 1.5 */ public String toString(PeriodFormatter formatter) { if (formatter == null) { return toString(); } return formatter.print(this); }
if (size() != other.size()) { return false; for (int i = 0, isize = size(); i < isize; i++) { if (getValue(i) != other.getValue(i) || getFieldType(i) != other.getFieldType(i)) { return false;
/** * Gets an array of the field types that this period supports. * <p> * The fields are returned largest to smallest, for example Hours, Minutes, Seconds. * * @return the fields supported in an array that may be altered, largest to smallest */ public DurationFieldType[] getFieldTypes() { DurationFieldType[] result = new DurationFieldType[size()]; for (int i = 0; i < result.length; i++) { result[i] = getFieldType(i); } return result; }
/** * Gets an array of the value of each of the fields that this period supports. * <p> * The fields are returned largest to smallest, for example Hours, Minutes, Seconds. * Each value corresponds to the same array index as <code>getFields()</code> * * @return the current values of each field in an array that may be altered, largest to smallest */ public int[] getValues() { int[] result = new int[size()]; for (int i = 0; i < result.length; i++) { result[i] = getValue(i); } return result; }
/** * Gets the value of one of the fields. * <p> * If the field type specified is not supported by the period then zero * is returned. * * @param type the field type to query, null returns zero * @return the value of that field, zero if field not supported */ public int get(DurationFieldType type) { int index = indexOf(type); if (index == -1) { return 0; } return getValue(index); }
/** * Gets the index of the field in this period. * * @param type the type to check, may be null which returns -1 * @return the index of -1 if not supported */ public int indexOf(DurationFieldType type) { return getPeriodType().indexOf(type); }