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? }