public Date getLatestStartDate() { Date latestStartDate = null; for ( CategoryOption co : getCategoryOptions() ) { if ( co.getStartDate() != null ) { latestStartDate = (latestStartDate == null || latestStartDate.before( co.getStartDate() ) ? co.getStartDate() : latestStartDate); } } return latestStartDate; }
/** * Gets a range of valid dates for this (attribute) cateogry option combo. * <p> * The earliest valid date is the latest start date (if any) from all the * category options associated with this option combo. * <p> * The latest valid date is the earliest end date (if any) from all the * category options associated with this option combo. * * @return valid date range for this (attribute) category option combo. */ public DateRange getDateRange() { Date latestStartDate = null; Date earliestEndDate = null; for ( CategoryOption option : getCategoryOptions() ) { if ( option.getStartDate() != null && (latestStartDate == null || option.getStartDate().compareTo( latestStartDate ) > 0) ) { latestStartDate = option.getStartDate(); } if ( option.getEndDate() != null && (earliestEndDate == null || option.getStartDate().compareTo( earliestEndDate ) < 0) ) { earliestEndDate = option.getEndDate(); } } return new DateRange( latestStartDate, earliestEndDate ); }
public Date getEarliestEndDate() { Date earliestEndDate = null; for ( CategoryOption co : getCategoryOptions() ) { if ( co.getEndDate() != null ) { earliestEndDate = (earliestEndDate == null || earliestEndDate.after( co.getEndDate() ) ? co.getStartDate() : earliestEndDate); } } return earliestEndDate; }
Date startDate = DateUtils.min( optionComboOptions.stream().map( co -> co.getStartDate() ).collect( Collectors.toSet() ) ); Date endDate = DateUtils.max( optionComboOptions.stream().map( co -> co.getEndDate() ).collect( Collectors.toSet() ) );