@Override public String toString() { return printDateTime( getCalendar() ); } }
/** * Returns the point in time that is at the beginning of this duration (relative to the given {@link DateTime}. * * @param end * end of the duration interval, must not be <code>null</code> * @return the point in time that marks the begin of the duration interval, never <code>null</code> */ public DateTime getBegin( DateTime end ) { Calendar before = Calendar.getInstance( end.getCalendar().getTimeZone() ); before.setTime( end.getDate() ); before.add( Calendar.YEAR, -years ); before.add( Calendar.MONTH, -months ); before.add( Calendar.DAY_OF_MONTH, -days ); before.add( Calendar.HOUR_OF_DAY, -hours ); before.add( Calendar.MINUTE, -minutes ); before.add( Calendar.SECOND, -seconds ); return new DateTime( before, end.isTimeZoneUnknown() ); }
/** * Returns the point in time that is at the end of this duration (relative to the given {@link DateTime}. * * @param begin * begin of the duration interval, must not be <code>null</code> * @return the point in time that marks the end of the duration interval, never <code>null</code> */ public DateTime getEnd( DateTime begin ) { Calendar after = Calendar.getInstance( begin.getCalendar().getTimeZone() ); after.setTime( begin.getDate() ); after.add( Calendar.YEAR, years ); after.add( Calendar.MONTH, months ); after.add( Calendar.DAY_OF_MONTH, days ); after.add( Calendar.HOUR_OF_DAY, hours ); after.add( Calendar.MINUTE, minutes ); after.add( Calendar.SECOND, seconds ); return new DateTime( after, begin.isTimeZoneUnknown() ); }
try { DateTime requestedDate = parseDateTime( date ); cal = requestedDate.getCalendar(); } catch ( IllegalArgumentException e ) { String msg = "Requested DATETIME: "