/* Returns the addition of two durations. */ public static SchemaDuration durationAdd(SchemaDuration duration1, SchemaDuration duration2) { SchemaDuration dur = new SchemaDuration(); dur.setNegative(false); // sets isempty to false int ym = duration1.getYearMonthValue() + duration2.getYearMonthValue(); long dt = duration1.getDayTimeValue() + duration2.getDayTimeValue(); if ((ym < 0 && dt > 0) || (ym > 0 && dt < 0)) throw new NotANumberException( "Invalid duration result, yearmonth part differs in sign from daytime part."); if (ym != 0) dur.setYearMonthValue(ym); if (dt != 0) dur.setDayTimeValue(dt); return dur; }