@Override
    public int compareTo(final DisabledDuration o) {
        int result = start.compareTo(o.getStart());
        if (result == 0) {
            if (end == null && o.getEnd() == null) {
                result = 0;
            } else if (end != null && o.getEnd() != null) {
                result = end.compareTo(o.getEnd());
            } else if (o.getEnd() == null) {
                return -1;
            } else {
                return 1;
            }
        }
        return result;
    }
@ Override public int compareTo ( final DisabledDuration o ) { int result = start . compareTo ( o . getStart ( ) ) ; if ( result == 0 ) { if ( end == null && o . getEnd ( ) == null ) { result = 0 ; } else if ( end != null && o . getEnd ( ) != null ) { result = end . compareTo ( o . getEnd ( ) ) ; } else if ( o . getEnd ( ) == null ) { return - 1 ; } else { return 1 ; } } return result ; }
Order by start date first and then end date