public DayTimeDurationValue convert(AtomicValue duration) { DurationValue d = (DurationValue)duration; if (d.signum() < 0) { return new DayTimeDurationValue(-d.getDays(), -d.getHours(), -d.getMinutes(), -d.getSeconds(), -d.getNanoseconds()); } else { return new DayTimeDurationValue(d.getDays(), d.getHours(), d.getMinutes(), d.getSeconds(), d.getNanoseconds()); } } }
int days = getDays(); int hours = getHours(); int minutes = getMinutes();
int days = getDays(); int hours = getHours(); int minutes = getMinutes();
public DayTimeDurationValue convert(AtomicValue duration) { DurationValue d = (DurationValue)duration; if (d.signum() < 0) { return new DayTimeDurationValue(-d.getDays(), -d.getHours(), -d.getMinutes(), -d.getSeconds(), -d.getNanoseconds()); } else { return new DayTimeDurationValue(d.getDays(), d.getHours(), d.getMinutes(), d.getSeconds(), d.getNanoseconds()); } } }
/** * Get a component of the normalized value */ public AtomicValue getComponent(int component) throws XPathException { switch (component) { case Component.YEAR: return Int64Value.makeIntegerValue((negative ? -getYears() : getYears())); case Component.MONTH: return Int64Value.makeIntegerValue((negative ? -getMonths() : getMonths())); case Component.DAY: return Int64Value.makeIntegerValue((negative ? -getDays() : getDays())); case Component.HOURS: return Int64Value.makeIntegerValue((negative ? -getHours() : getHours())); case Component.MINUTES: return Int64Value.makeIntegerValue((negative ? -getMinutes() : getMinutes())); case Component.SECONDS: FastStringBuffer sb = new FastStringBuffer(16); String ms = ("000000" + microseconds); ms = ms.substring(ms.length() - 6); sb.append((negative ? "-" : "") + getSeconds() + '.' + ms); return (AtomicValue)DecimalValue.makeDecimalValue(sb, false); case Component.WHOLE_SECONDS: return Int64Value.makeIntegerValue((negative ? -seconds : seconds)); case Component.MICROSECONDS: return new Int64Value((negative ? -microseconds : microseconds)); default: throw new IllegalArgumentException("Unknown component for duration: " + component); } }
/** * Get a component of the normalized value */ public AtomicValue getComponent(int component) throws XPathException { switch (component) { case Component.YEAR: return Int64Value.makeIntegerValue((negative ? -getYears() : getYears())); case Component.MONTH: return Int64Value.makeIntegerValue((negative ? -getMonths() : getMonths())); case Component.DAY: return Int64Value.makeIntegerValue((negative ? -getDays() : getDays())); case Component.HOURS: return Int64Value.makeIntegerValue((negative ? -getHours() : getHours())); case Component.MINUTES: return Int64Value.makeIntegerValue((negative ? -getMinutes() : getMinutes())); case Component.SECONDS: FastStringBuffer sb = new FastStringBuffer(16); String ms = ("000000" + microseconds); ms = ms.substring(ms.length() - 6); sb.append((negative ? "-" : "") + getSeconds() + '.' + ms); return (AtomicValue)DecimalValue.makeDecimalValue(sb, false); case Component.WHOLE_SECONDS: return Int64Value.makeIntegerValue((negative ? -seconds : seconds)); case Component.MICROSECONDS: return new Int64Value((negative ? -microseconds : microseconds)); default: throw new IllegalArgumentException("Unknown component for duration: " + component); } }