/** * Get this object as a <code>MutablePeriod</code>. * <p> * This will always return a new <code>MutablePeriod</code> with the same fields. * * @return a MutablePeriod using the same field set and values */ public MutablePeriod toMutablePeriod() { return new MutablePeriod(this); }
/** * Get this object as a <code>MutablePeriod</code>. * <p> * This will always return a new <code>MutablePeriod</code> with the same fields. * * @return a MutablePeriod using the same field set and values */ public MutablePeriod toMutablePeriod() { return new MutablePeriod(this); }
/** * Get this object as a <code>MutablePeriod</code>. * <p> * This will always return a new <code>MutablePeriod</code> with the same fields. * The period will use <code>PeriodType.standard()</code>. * * @return a MutablePeriod using the same field set and values */ public MutablePeriod toMutablePeriod() { MutablePeriod period = new MutablePeriod(); period.add(this); return period; }
/** * Get this object as a <code>MutablePeriod</code>. * <p> * This will always return a new <code>MutablePeriod</code> with the same fields. * The period will use <code>PeriodType.standard()</code>. * * @return a MutablePeriod using the same field set and values */ public MutablePeriod toMutablePeriod() { MutablePeriod period = new MutablePeriod(); period.add(this); return period; }
ReadWritablePeriod parsedPeriod = new MutablePeriod(); int parsePos = parser.parseInto(parsedPeriod, text, position, locale); if (parsePos >= position) {
/** * Parses a period from the given text, returning a new MutablePeriod. * * @param text text to parse * @return parsed value in a MutablePeriod object * @throws IllegalArgumentException if any field is out of range */ public MutablePeriod parseMutablePeriod(String text) { checkParser(); MutablePeriod period = new MutablePeriod(0, iParseType); int newPos = getParser().parseInto(period, text, 0, iLocale); if (newPos >= 0) { if (newPos >= text.length()) { return period; } } else { newPos = ~newPos; } throw new IllegalArgumentException(FormatUtils.createErrorMessage(text, newPos)); }
/** * Parses a period from the given text, returning a new MutablePeriod. * * @param text text to parse * @return parsed value in a MutablePeriod object * @throws IllegalArgumentException if any field is out of range */ public MutablePeriod parseMutablePeriod(String text) { checkParser(); MutablePeriod period = new MutablePeriod(0, iParseType); int newPos = getParser().parseInto(period, text, 0, iLocale); if (newPos >= 0) { if (newPos >= text.length()) { return period; } } else { newPos = ~newPos; } throw new IllegalArgumentException(FormatUtils.createErrorMessage(text, newPos)); }
return this; } else { MutablePeriod p = new MutablePeriod(); for (int i = 0; i < period.size(); i++) { int oldVal = period.getValue(i);
/** * Creates a new period based on another using the {@link ConverterManager}. * * @param period the period to convert * @param type which set of fields this period supports, null means use type from object * @param chrono the chronology to use, null means ISO default * @throws IllegalArgumentException if period is invalid * @throws IllegalArgumentException if an unsupported field's value is non-zero */ protected BasePeriod(Object period, PeriodType type, Chronology chrono) { super(); PeriodConverter converter = ConverterManager.getInstance().getPeriodConverter(period); type = (type == null ? converter.getPeriodType(period) : type); type = checkPeriodType(type); iType = type; if (this instanceof ReadWritablePeriod) { iValues = new int[size()]; chrono = DateTimeUtils.getChronology(chrono); converter.setInto((ReadWritablePeriod) this, period, chrono); } else { iValues = new MutablePeriod(period, type, chrono).getValues(); } }
/** * Creates a new period based on another using the {@link ConverterManager}. * * @param period the period to convert * @param type which set of fields this period supports, null means use type from object * @param chrono the chronology to use, null means ISO default * @throws IllegalArgumentException if period is invalid * @throws IllegalArgumentException if an unsupported field's value is non-zero */ protected BasePeriod(Object period, PeriodType type, Chronology chrono) { super(); PeriodConverter converter = ConverterManager.getInstance().getPeriodConverter(period); type = (type == null ? converter.getPeriodType(period) : type); type = checkPeriodType(type); iType = type; if (this instanceof ReadWritablePeriod) { iValues = new int[size()]; chrono = DateTimeUtils.getChronology(chrono); converter.setInto((ReadWritablePeriod) this, period, chrono); } else { iValues = new MutablePeriod(period, type, chrono).getValues(); } }
/** * Get this object as a <code>MutablePeriod</code>. * <p> * This will always return a new <code>MutablePeriod</code> with the same fields. * * @return a MutablePeriod using the same field set and values */ public MutablePeriod toMutablePeriod() { return new MutablePeriod(this); }
/** * Get this object as a <code>MutablePeriod</code>. * <p> * This will always return a new <code>MutablePeriod</code> with the same fields. * The period will use <code>PeriodType.standard()</code>. * * @return a MutablePeriod using the same field set and values */ public MutablePeriod toMutablePeriod() { MutablePeriod period = new MutablePeriod(); period.add(this); return period; }
String periodString = "98d 01h 23m 45s"; PeriodParser parser = new PeriodFormatterBuilder() .appendDays().appendSuffix("d ") .appendHours().appendSuffix("h ") .appendMinutes().appendSuffix("m ") .appendSeconds().appendSuffix("s ") .toParser(); MutablePeriod period = new MutablePeriod(); parser.parseInto(period, periodString, 0, Locale.getDefault()); long millis = period.toDurationFrom(new DateTime(0)).getMillis();
/** * Parses a period from the given text, returning a new MutablePeriod. * * @param text text to parse * @return parsed value in a MutablePeriod object * @throws IllegalArgumentException if any field is out of range */ public MutablePeriod parseMutablePeriod(String text) { checkParser(); MutablePeriod period = new MutablePeriod(0, iParseType); int newPos = getParser().parseInto(period, text, 0, iLocale); if (newPos >= 0) { if (newPos >= text.length()) { return period; } } else { newPos = ~newPos; } throw new IllegalArgumentException(FormatUtils.createErrorMessage(text, newPos)); }
/** * Get this object as a <code>MutablePeriod</code>. * <p> * This will always return a new <code>MutablePeriod</code> with the same fields. * * @return a MutablePeriod using the same field set and values */ public MutablePeriod toMutablePeriod() { return new MutablePeriod(this); }
/** * Creates a new period based on another using the {@link ConverterManager}. * * @param period the period to convert * @param type which set of fields this period supports, null means use type from object * @param chrono the chronology to use, null means ISO default * @throws IllegalArgumentException if period is invalid * @throws IllegalArgumentException if an unsupported field's value is non-zero */ protected BasePeriod(Object period, PeriodType type, Chronology chrono) { super(); PeriodConverter converter = ConverterManager.getInstance().getPeriodConverter(period); type = (type == null ? converter.getPeriodType(period) : type); type = checkPeriodType(type); iType = type; if (this instanceof ReadWritablePeriod) { iValues = new int[size()]; chrono = DateTimeUtils.getChronology(chrono); converter.setInto((ReadWritablePeriod) this, period, chrono); } else { iValues = new MutablePeriod(period, type, chrono).getValues(); } }
/** * Get this object as a <code>MutablePeriod</code>. * <p> * This will always return a new <code>MutablePeriod</code> with the same fields. * The period will use <code>PeriodType.standard()</code>. * * @return a MutablePeriod using the same field set and values */ public MutablePeriod toMutablePeriod() { MutablePeriod period = new MutablePeriod(); period.add(this); return period; }
/** * Get this object as a <code>MutablePeriod</code>. * <p> * This will always return a new <code>MutablePeriod</code> with the same fields. * The period will use <code>PeriodType.standard()</code>. * * @return a MutablePeriod using the same field set and values */ public MutablePeriod toMutablePeriod() { MutablePeriod period = new MutablePeriod(); period.add(this); return period; }
/** * Get this object as a <code>MutablePeriod</code>. * <p> * This will always return a new <code>MutablePeriod</code> with the same fields. * The period will use <code>PeriodType.standard()</code>. * * @return a MutablePeriod using the same field set and values */ public MutablePeriod toMutablePeriod() { MutablePeriod period = new MutablePeriod(); period.add(this); return period; }
/** * Get this object as a <code>MutablePeriod</code>. * <p> * This will always return a new <code>MutablePeriod</code> with the same fields. * The period will use <code>PeriodType.standard()</code>. * * @return a MutablePeriod using the same field set and values */ public MutablePeriod toMutablePeriod() { MutablePeriod period = new MutablePeriod(); period.add(this); return period; }