/** * Sets the given ReadWritableDuration to zero milliseconds. * * @param duration duration to get modified * @param object the object to convert, which is null * @param chrono the chronology to use * @throws NullPointerException if the duration is null */ public void setInto(ReadWritablePeriod duration, Object object, Chronology chrono) { duration.setPeriod((Period) null); }
/** * Extracts duration values from an object of this converter's type, and * sets them into the given ReadWritableDuration. * * @param period period to get modified * @param object the String to convert, must not be null * @param chrono the chronology to use * @return the millisecond duration * @throws ClassCastException if the object is invalid */ public void setInto(ReadWritablePeriod period, Object object, Chronology chrono) { String str = (String) object; PeriodFormatter parser = ISOPeriodFormat.standard(); period.clear(); int pos = parser.parseInto(period, str, 0); if (pos < str.length()) { if (pos < 0) { // Parse again to get a better exception thrown. parser.withParseType(period.getPeriodType()).parseMutablePeriod(str); } throw new IllegalArgumentException("Invalid format: \"" + str + '"'); } }
void setFieldValue(ReadWritablePeriod period, int field, int value) { switch (field) { default: break; case YEARS: period.setYears(value); break; case MONTHS: period.setMonths(value); break; case WEEKS: period.setWeeks(value); break; case DAYS: period.setDays(value); break; case HOURS: period.setHours(value); break; case MINUTES: period.setMinutes(value); break; case SECONDS: period.setSeconds(value); break; case MILLIS: period.setMillis(value); break; } }
/** * Extracts duration values from an object of this converter's type, and * sets them into the given ReadWritableDuration. * * @param writablePeriod period to get modified * @param object the object to convert, must not be null * @param chrono the chronology to use, must not be null * @throws NullPointerException if the duration or object is null * @throws ClassCastException if the object is an invalid type * @throws IllegalArgumentException if the object is invalid */ public void setInto(ReadWritablePeriod writablePeriod, Object object, Chronology chrono) { ReadableDuration dur = (ReadableDuration) object; chrono = DateTimeUtils.getChronology(chrono); long duration = dur.getMillis(); int[] values = chrono.get(writablePeriod, duration); for (int i = 0; i < values.length; i++) { writablePeriod.setValue(i, values[i]); } }
if (!mustParse && !isSupported(period.getPeriodType(), iFieldType)) {
/** * Extracts duration values from an object of this converter's type, and * sets them into the given ReadWritableDuration. * * @param writablePeriod period to get modified * @param object the object to convert, must not be null * @param chrono the chronology to use, must not be null * @throws NullPointerException if the duration or object is null * @throws ClassCastException if the object is an invalid type * @throws IllegalArgumentException if the object is invalid */ public void setInto(ReadWritablePeriod writablePeriod, Object object, Chronology chrono) { ReadableDuration dur = (ReadableDuration) object; chrono = DateTimeUtils.getChronology(chrono); long duration = dur.getMillis(); int[] values = chrono.get(writablePeriod, duration); for (int i = 0; i < values.length; i++) { writablePeriod.setValue(i, values[i]); } }
if (!mustParse && !isSupported(period.getPeriodType(), iFieldType)) {
void setFieldValue(ReadWritablePeriod period, int field, int value) { switch (field) { default: break; case YEARS: period.setYears(value); break; case MONTHS: period.setMonths(value); break; case WEEKS: period.setWeeks(value); break; case DAYS: period.setDays(value); break; case HOURS: period.setHours(value); break; case MINUTES: period.setMinutes(value); break; case SECONDS: period.setSeconds(value); break; case MILLIS: period.setMillis(value); break; } }
/** * Extracts duration values from an object of this converter's type, and * sets them into the given ReadWritableDuration. * * @param period period to get modified * @param object the String to convert, must not be null * @param chrono the chronology to use * @return the millisecond duration * @throws ClassCastException if the object is invalid */ public void setInto(ReadWritablePeriod period, Object object, Chronology chrono) { String str = (String) object; PeriodFormatter parser = ISOPeriodFormat.standard(); period.clear(); int pos = parser.parseInto(period, str, 0); if (pos < str.length()) { if (pos < 0) { // Parse again to get a better exception thrown. parser.withParseType(period.getPeriodType()).parseMutablePeriod(str); } throw new IllegalArgumentException("Invalid format: \"" + str + '"'); } }
/** * Extracts duration values from an object of this converter's type, and * sets them into the given ReadWritablePeriod. * * @param duration duration to get modified * @param object the object to convert, must not be null * @param chrono the chronology to use * @throws NullPointerException if the duration or object is null * @throws ClassCastException if the object is an invalid type * @throws IllegalArgumentException if the object is invalid */ public void setInto(ReadWritablePeriod duration, Object object, Chronology chrono) { duration.setPeriod((ReadablePeriod) object); }
/** * Sets the values of the mutable duration from the specified interval. * * @param writablePeriod the period to modify * @param object the interval to set from * @param chrono the chronology to use */ public void setInto(ReadWritablePeriod writablePeriod, Object object, Chronology chrono) { ReadableInterval interval = (ReadableInterval) object; chrono = (chrono != null ? chrono : DateTimeUtils.getIntervalChronology(interval)); long start = interval.getStartMillis(); long end = interval.getEndMillis(); int[] values = chrono.get(writablePeriod, start, end); for (int i = 0; i < values.length; i++) { writablePeriod.setValue(i, values[i]); } }
if (!mustParse && !isSupported(period.getPeriodType(), iFieldType)) {
void setFieldValue(ReadWritablePeriod period, int field, int value) { switch (field) { default: break; case YEARS: period.setYears(value); break; case MONTHS: period.setMonths(value); break; case WEEKS: period.setWeeks(value); break; case DAYS: period.setDays(value); break; case HOURS: period.setHours(value); break; case MINUTES: period.setMinutes(value); break; case SECONDS: period.setSeconds(value); break; case MILLIS: period.setMillis(value); break; } }
/** * Extracts duration values from an object of this converter's type, and * sets them into the given ReadWritableDuration. * * @param period period to get modified * @param object the String to convert, must not be null * @param chrono the chronology to use * @return the millisecond duration * @throws ClassCastException if the object is invalid */ public void setInto(ReadWritablePeriod period, Object object, Chronology chrono) { String str = (String) object; PeriodFormatter parser = ISOPeriodFormat.standard(); period.clear(); int pos = parser.parseInto(period, str, 0); if (pos < str.length()) { if (pos < 0) { // Parse again to get a better exception thrown. parser.withParseType(period.getPeriodType()).parseMutablePeriod(str); } throw new IllegalArgumentException("Invalid format: \"" + str + '"'); } }
/** * Sets the given ReadWritableDuration to zero milliseconds. * * @param duration duration to get modified * @param object the object to convert, which is null * @param chrono the chronology to use * @throws NullPointerException if the duration is null */ public void setInto(ReadWritablePeriod duration, Object object, Chronology chrono) { duration.setPeriod((Period) null); }
/** * Sets the values of the mutable duration from the specified interval. * * @param writablePeriod the period to modify * @param object the interval to set from * @param chrono the chronology to use */ public void setInto(ReadWritablePeriod writablePeriod, Object object, Chronology chrono) { ReadableInterval interval = (ReadableInterval) object; chrono = (chrono != null ? chrono : DateTimeUtils.getIntervalChronology(interval)); long start = interval.getStartMillis(); long end = interval.getEndMillis(); int[] values = chrono.get(writablePeriod, start, end); for (int i = 0; i < values.length; i++) { writablePeriod.setValue(i, values[i]); } }
if (!mustParse && !isSupported(period.getPeriodType(), iFieldType)) {
void setFieldValue(ReadWritablePeriod period, int field, int value) { switch (field) { default: break; case YEARS: period.setYears(value); break; case MONTHS: period.setMonths(value); break; case WEEKS: period.setWeeks(value); break; case DAYS: period.setDays(value); break; case HOURS: period.setHours(value); break; case MINUTES: period.setMinutes(value); break; case SECONDS: period.setSeconds(value); break; case MILLIS: period.setMillis(value); break; } }
/** * Extracts duration values from an object of this converter's type, and * sets them into the given ReadWritableDuration. * * @param period period to get modified * @param object the String to convert, must not be null * @param chrono the chronology to use * @return the millisecond duration * @throws ClassCastException if the object is invalid */ public void setInto(ReadWritablePeriod period, Object object, Chronology chrono) { String str = (String) object; PeriodFormatter parser = ISOPeriodFormat.standard(); period.clear(); int pos = parser.parseInto(period, str, 0); if (pos < str.length()) { if (pos < 0) { // Parse again to get a better exception thrown. parser.withParseType(period.getPeriodType()).parseMutablePeriod(str); } throw new IllegalArgumentException("Invalid format: \"" + str + '"'); } }
/** * Extracts duration values from an object of this converter's type, and * sets them into the given ReadWritablePeriod. * * @param duration duration to get modified * @param object the object to convert, must not be null * @param chrono the chronology to use * @throws NullPointerException if the duration or object is null * @throws ClassCastException if the object is an invalid type * @throws IllegalArgumentException if the object is invalid */ public void setInto(ReadWritablePeriod duration, Object object, Chronology chrono) { duration.setPeriod((ReadablePeriod) object); }