if ( duration.getYears() > 0 ) { result.append( duration.getYears() ).append( 'Y' ); if ( duration.getMonths() > 0 ) { result.append( duration.getMonths() ).append( 'M' ); if ( duration.getDays() > 0 ) { result.append( duration.getDays() ).append( 'D' ); if ( duration.getHours() > 0 || duration.getMinutes() > 0 || duration.getSeconds() > 0 ) { result.append( 'T' ); if ( duration.getHours() > 0 ) { result.append( duration.getHours() ).append( 'H' ); if ( duration.getMinutes() > 0 ) { result.append( duration.getMinutes() ).append( 'M' ); if ( duration.getSeconds() > 0 ) { result.append( duration.getSeconds() ).append( 'S' );
private static double getAsDouble( final Object o ) { if ( o instanceof Double ) { return (Double) o; } if ( o instanceof Integer ) { return (Integer) o; } if ( o instanceof Long ) { return (Long) o; } if ( o instanceof Date ) { return ( (Date) o ).getTime(); } if ( o instanceof Duration ) { return ( (Duration) o ).getEnd( new DateTime( new Date( 0 ), null ) ).getTimeInMilliseconds(); } return 0; // what else? }
int seconds = getIntFromMatcher( matcher, 14 ); return new Duration( years, months, days, hours, minutes, seconds );