EthiopianCalendar extends ChronologyBasedCalendar { @Override public DateTimeUnit plusDays( DateTimeUnit dateTimeUnit, int days ) { if ( days < 0 ) { return minusDays( dateTimeUnit, Math.abs( days ) ); } int curYear = dateTimeUnit.getYear(); int curMonth = dateTimeUnit.getMonth(); int curDay = dateTimeUnit.getDay(); int dayOfWeek = dateTimeUnit.getDayOfWeek(); while ( days != 0 ) { curDay++; if ( curDay > 30 ) { curMonth++; curDay = 1; } if ( curMonth > 12 ) { curYear++; curMonth = 1; } dayOfWeek++; if ( dayOfWeek > 7 ) { dayOfWeek = 1; } days--; } return new DateTimeUnit( curYear, curMonth, curDay, dayOfWeek ); } protected  EthiopianCalendar(); static Calendar getInstance(); @Override String name(); @Override DateTimeUnit toIso( DateTimeUnit dateTimeUnit ); @Override DateTimeUnit fromIso( Date date ); @Override DateTimeUnit fromIso( DateTimeUnit dateTimeUnit ); @Override DateTimeUnit plusDays( DateTimeUnit dateTimeUnit, int days ); @Override DateTimeUnit minusDays( DateTimeUnit dateTimeUnit, int days ); @Override DateTimeUnit plusWeeks( DateTimeUnit dateTimeUnit, int weeks ); @Override DateTimeUnit minusWeeks( DateTimeUnit dateTimeUnit, int weeks ); @Override DateTimeUnit plusMonths( DateTimeUnit dateTimeUnit, int months ); @Override DateTimeUnit minusMonths( DateTimeUnit dateTimeUnit, int months ); @Override DateTimeUnit plusYears( DateTimeUnit dateTimeUnit, int years ); @Override DateTimeUnit minusYears( DateTimeUnit dateTimeUnit, int years ); @Override int daysInYear( int year ); @Override int daysInMonth( int year, int month ); @Override int daysInWeek(); @Override DateTimeUnit isoStartOfYear( int year );  }
@Test public void testPlusDays() { DateTimeUnit dateTimeUnit = new DateTimeUnit( 2006, 1, 1 ); DateTimeUnit testDateTimeUnit = calendar.plusDays( dateTimeUnit, 43 ); assertEquals( 2006, testDateTimeUnit.getYear() ); assertEquals( 2, testDateTimeUnit.getMonth() ); assertEquals( 14, testDateTimeUnit.getDay() ); testDateTimeUnit = calendar.plusDays( dateTimeUnit, 65 ); assertEquals( 2006, testDateTimeUnit.getYear() ); assertEquals( 3, testDateTimeUnit.getMonth() ); assertEquals( 6, testDateTimeUnit.getDay() ); testDateTimeUnit = calendar.plusDays( dateTimeUnit, (12 * 30) + 5 ); assertEquals( 2007, testDateTimeUnit.getYear() ); assertEquals( 1, testDateTimeUnit.getMonth() ); assertEquals( 6, testDateTimeUnit.getDay() ); dateTimeUnit = new DateTimeUnit( 2006, 2, 29 ); testDateTimeUnit = calendar.plusDays( dateTimeUnit, 10 ); assertEquals( 2006, testDateTimeUnit.getYear() ); assertEquals( 3, testDateTimeUnit.getMonth() ); assertEquals( 9, testDateTimeUnit.getDay() ); dateTimeUnit = new DateTimeUnit( 2006, 3, 9 ); testDateTimeUnit = calendar.plusDays( dateTimeUnit, - 1 ); assertEquals( 2006, testDateTimeUnit.getYear() ); assertEquals( 3, testDateTimeUnit.getMonth() ); assertEquals( 8, testDateTimeUnit.getDay() ); dateTimeUnit = new DateTimeUnit( 2006, 1, 1 ); testDateTimeUnit = calendar.plusDays( dateTimeUnit, - 1 ); assertEquals( 2005, testDateTimeUnit.getYear() ); assertEquals( 12, testDateTimeUnit.getMonth() ); assertEquals( 30, testDateTimeUnit.getDay() ); }