/** * Create a Duration from a ISO8601 string presentation * * @param value * @throws IllegalArgumentException * if value null or wrong format */ public static DvDuration getInstance(String value) { if (value == null) { throw new IllegalArgumentException("null value"); } if (!value.matches(PATTERN)) { throw new IllegalArgumentException("Wrong duration format: " + value); } Period period = null; final String suppliedValue = value; if (value.startsWith("-")) { value = value.substring(1, value.length()); // skip '-' period = ISOPeriodFormat.standard().parsePeriod(value); period = negatePeriod(period); } else { period = ISOPeriodFormat.standard().parsePeriod(value); } DvDuration duration = new DvDuration(null, null, null, 0.0, false, null, period); duration.setValue(suppliedValue); // If we don't set this we cannot reconstruct the original constraint if 0s or 0h etc if all the same period, but the constraint in the ADL / XML serialisation still looks different return duration; }
/** * Create a Duration from a ISO8601 string presentation * * @param value * @throws IllegalArgumentException * if value null or wrong format */ public static DvDuration getInstance(String value) { if (value == null) { throw new IllegalArgumentException("null value"); } if (!value.matches(PATTERN)) { throw new IllegalArgumentException("Wrong duration format: " + value); } Period period = null; final String suppliedValue = value; if (value.startsWith("-")) { value = value.substring(1, value.length()); // skip '-' period = ISOPeriodFormat.standard().parsePeriod(value); period = negatePeriod(period); } else { period = ISOPeriodFormat.standard().parsePeriod(value); } DvDuration duration = new DvDuration(null, null, null, 0.0, false, null, period); duration.setValue(suppliedValue); // If we don't set this we cannot reconstruct the original constraint if 0s or 0h etc if all the same period, but the constraint in the ADL / XML serialisation still looks different return duration; }
/** * Negated version of current object * * @return negated version */ public DvDuration negate() { return new DvDuration(getOtherReferenceRanges(), getNormalRange(), getNormalStatus(), getAccuracy(), isAccuracyPercent(), getMagnitudeStatus(), negatePeriod(period)); }
/** * Negated version of current object * * @return negated version */ public DvDuration negate() { return new DvDuration(getOtherReferenceRanges(), getNormalRange(), getNormalStatus(), getAccuracy(), isAccuracyPercent(), getMagnitudeStatus(), negatePeriod(period)); }