Example usage for java.util Date equals

List of usage examples for java.util Date equals

Introduction

In this page you can find the example usage for java.util Date equals.

Prototype

public boolean equals(Object obj) 

Source Link

Document

Compares two dates for equality.

Usage

From source file:org.webical.util.RecurrenceUtils.java

/**
 * Checks if the {@link Event} is applicable for the given range taking into account recurrence information
 * @param event the {@link Event}//from ww  w .  j  av  a2  s  .  c o m
 * @param startDate the start of the range
 * @param endDate the end of the range
 * @return true if the {@link Event} is applicable for this range
 * @throws ParseException
 */
public static boolean isApplicableForDateRange(Event event, Date startDate, Date endDate)
        throws ParseException {
    if (event.getDtStart() == null)
        return false;

    if (isRecurrent(event)) {
        if (log.isDebugEnabled())
            log.debug("isApplicableForDateRange:Recurrent " + event.getSummary());

        //Property: RRULE
        Recur recur = null;
        try {
            if (event.getrRule() != null) {
                recur = new Recur(event.getrRule().iterator().next());
            }
        } catch (ParseException e) {
            log.error("Could not parse recurrence information", e);
            throw e;
        }

        ExRule exRule = new ExRule();
        exRule.setRecur(recur);

        DateTime fromDate = new DateTime(event.getDtStart());
        DateTime dtStart = new DateTime(startDate.getTime() - 1000);
        DateTime dtEnd = new DateTime(endDate.getTime() - 1000);

        DateList datesFromRecur = recur.getDates(fromDate, dtStart, dtEnd, Value.DATE_TIME);
        Set<Date> dates = event.getrDate();

        //Property RDate
        for (Date date : dates) {
            datesFromRecur.add(date);
        }

        if (datesFromRecur.size() > 0) { //Property: EXDATE
            for (Iterator<Date> i = event.getExDate().iterator(); i.hasNext();) {
                Date datum = (Date) i.next();
                if (startDate.equals(new net.fortuna.ical4j.model.Date(datum.getTime()))) {
                    return false;
                }
            }

            //PROPERTY: EXRULE
            if (event.getExRule().iterator().hasNext()) {
                Recur exRecur = null;
                try {
                    exRecur = new Recur(event.getExRule().iterator().next());
                } catch (ParseException e) {
                    log.error("Could not parse recurrence information", e);
                    throw e;
                }

                DateList datesFromExRule = exRecur.getDates(fromDate, dtStart, dtEnd, Value.DATE_TIME);
                if (datesFromExRule.size() > 0) {
                    return false;
                }
            }
            return true;
        }
    } else if ((event.getDtStart().before(startDate) && event.getDtEnd().before(startDate))
            || (event.getDtStart().after(endDate) && event.getDtEnd().after(endDate))) {
        // Event is not in daterange
        return false;
    } else {
        return true;
    }
    return false;
}

From source file:com.virtusa.akura.student.controller.StudentLeaveController.java

/**
 * This method is to Add/Edit/Delete student leave.
 * /*ww  w  .  ja  v  a  2  s. c om*/
 * @param studentLeave - {@link StudentLeave}
 * @param bindingResult - {@link BindingResult}
 * @param request - {@link HttpServletRequest}
 * @param model - {@link ModelMap}
 * @param session - {@link HttpSession}
 * @return the name of the view.
 * @throws AkuraAppException - The exception details that occurred when processing.
 */
@RequestMapping(value = REQ_MAP_VALUE_SAVEORUPDATE, method = RequestMethod.POST)
public String saveOrUpdateStudentLeave(@ModelAttribute(MODEL_ATT_STUDENT_LEAVE) StudentLeave studentLeave,
        BindingResult bindingResult, HttpServletRequest request, ModelMap model, HttpSession session)
        throws AkuraAppException {

    studentLeaveValidator.validate(studentLeave, bindingResult);

    if (request.getParameter(ATTENDANCE_PAGE).equals(TRUE)) {
        model.addAttribute(ATTENDANCE_PAGE, TRUE);
    } else {
        model.addAttribute(ATTENDANCE_PAGE, FALSE);
    }

    if (bindingResult.hasErrors()) {
        setRatingValue(model, session);
        return VIEW_GET_STUDENT_LEAVE;
    } else {

        Date dateFrom = studentLeave.getFromDate();
        int studentId = (Integer) session.getAttribute(STUDENT_ID);

        // if the first date of the student is less than the start date of the leave,
        // save or edit.
        Date startedDate = studentService.getStudentStartedDate(studentId);

        if (startedDate != null && dateFrom.after(startedDate)
                || (startedDate != null && startedDate.equals(dateFrom))) {
            Date dateTo = studentLeave.getToDate();
            Calendar fromDate = Calendar.getInstance();
            fromDate.setTime(dateFrom);
            Calendar toDate = Calendar.getInstance();
            toDate.setTime(dateTo);

            List<Holiday> holidayList = getHolidayList(dateFrom, dateTo);

            int holidayCount = HolidayUtil.countHolidays(fromDate, toDate, holidayList);
            int daysCount = StaticDataUtil.daysBetween(dateFrom, dateTo) - holidayCount;

            if (daysCount > MAXIMUM_LEAVE_DAYS) {

                if (!studentLeave.getCertificategiven()) {
                    String message = new ErrorMsgLoader().getErrorMessage(LEAVE_ERROR);
                    model.addAttribute(MESSAGE, message);
                    return VIEW_GET_STUDENT_LEAVE;
                }

            } else if (daysCount == 0) {
                String message = new ErrorMsgLoader().getErrorMessage(LEAVE_ON_HOLIDAY_DATES);
                model.addAttribute(MESSAGE, message);
                return VIEW_GET_STUDENT_LEAVE;
            }
            String reason = StaticDataUtil.removeExtraWhiteSpace(studentLeave.getReason());

            List<StudentLeave> existLeave = studentService.findAlreadyExistLeave(studentId, dateFrom, dateTo);

            if ((!existLeave.isEmpty() && studentLeave.getStudentLeaveId() == 0) || (!existLeave.isEmpty()
                    && existLeave.get(0).getStudentLeaveId() != studentLeave.getStudentLeaveId())) {
                model.addAttribute(MESSAGE, new ErrorMsgLoader().getErrorMessage(ALREADY_EXIST));
                return VIEW_GET_STUDENT_LEAVE;
            } else if (studentService.isPresentDay(studentId, dateFrom, dateTo)) {
                String message = new ErrorMsgLoader().getErrorMessage(STUDENT_PRESENT_DATE_ERROR);
                model.addAttribute(MESSAGE, message);
                return VIEW_GET_STUDENT_LEAVE;
            } else {
                studentLeave.setStudentId(studentId);
                studentLeave.setReason(reason);
                studentLeave.setNoOfDays(daysCount);

                if (studentLeave.getStudentLeaveId() == 0) {
                    studentService.createStudentLeave(studentLeave);
                } else {
                    studentService.updateStudentLeave(studentLeave);
                }
            }
        } else {
            if (startedDate != null) {
                String message = new ErrorMsgLoader().getErrorMessage(STUDENT_FIRST_DATE_ERROR);
                model.addAttribute(MESSAGE, message);
                return VIEW_GET_STUDENT_LEAVE;
            }
        }
    }

    return VIEW_POST_MANAGE_STUDENT_LEAVE;
}

From source file:com.qcadoo.mes.masterOrders.validators.MasterOrderValidators.java

public boolean checkIfCanSetDeadline(final Entity masterOrder, final Object fieldNewValue) {
    boolean isValid = true;

    List<Entity> orders = masterOrderOrdersDataProvider.findBelongingOrders(masterOrder, null, null, null);

    if (orders.isEmpty()) {
        return isValid;
    }/*from  w  w w .jav  a2s.  c o  m*/

    Date deadlineInMasterOrder = (Date) fieldNewValue;

    if (deadlineInMasterOrder == null) {
        return isValid;
    }

    for (Entity order : orders) {
        Date deadlineInOrder = order.getDateField(OrderFields.DEADLINE);

        if (deadlineInOrder == null) {
            isValid = false;
        } else if (!deadlineInMasterOrder.equals(deadlineInOrder)) {
            isValid = false;
        }
    }

    return isValid;
}

From source file:com.mb.framework.util.DateTimeUtil.java

/**
 * This method is used for checking whether the target date is holiday
 * /*from  ww w . jav a2  s.  co  m*/
 * @param calendarDay
 * @param holidays
 * @return
 * @throws ParseException
 */
public static boolean isHolidayWeekend(Date calendarDay, List<Date> holidays) throws ParseException {
    if (isWeekEnd(calendarDay))
        return true;

    boolean isHolidayWeek = false;
    Date tempCalendarDay = getDateWithoutTime(calendarDay);
    if (holidays != null) {
        for (Date holiday : holidays) {
            if (tempCalendarDay.equals(holiday)) {
                isHolidayWeek = true;
                break;
            }
        }
    }
    return isHolidayWeek;
}

From source file:com.dianping.lion.service.impl.ConfigReleaseServiceImpl.java

@SuppressWarnings("unchecked")
@Override/*w  w w.  j  ava  2s  . c o  m*/
public ConfigRollbackResult rollbackSnapshotSet(ConfigSnapshotSet snapshotSet, String[] keys) {
    ConfigRollbackResult rollbackResult = new ConfigRollbackResult();
    final int projectId = snapshotSet.getProjectId();
    final int envId = snapshotSet.getEnvId();
    try {
        List<ConfigSnapshot> configSnapshots = configReleaseDao.findConfigSnapshots(snapshotSet.getId());
        List<ConfigInstanceSnapshot> configInstSnapshots = configReleaseDao
                .findConfigInstSnapshots(snapshotSet.getId());
        List<Config> currentConfigs = configService.findConfigs(projectId);
        List<ConfigInstance> currentConfigInsts = configService.findInstances(projectId, envId);
        Map<Integer, Date> modifyTimes = configService.findModifyTime(projectId, envId);

        Map<String, ConfigSnapshot> configSnapshotMap = new HashMap<String, ConfigSnapshot>(
                configSnapshots.size());
        for (ConfigSnapshot configSnapshot : configSnapshots) {
            configSnapshotMap.put(configSnapshot.getKey(), configSnapshot);
        }
        Map<Integer, List<ConfigInstanceSnapshot>> configInstSnapshotMap = new HashMap<Integer, List<ConfigInstanceSnapshot>>(
                configSnapshots.size());
        for (ConfigInstanceSnapshot configInstSnapshot : configInstSnapshots) {
            List<ConfigInstanceSnapshot> instList = configInstSnapshotMap.get(configInstSnapshot.getConfigId());
            if (instList == null) {
                instList = new ArrayList<ConfigInstanceSnapshot>();
                configInstSnapshotMap.put(configInstSnapshot.getConfigId(), instList);
            }
            instList.add(configInstSnapshot);
        }
        Set<String> configSnapshotKeys = configSnapshotMap.keySet();

        final Map<String, Config> currentConfigMap = new HashMap<String, Config>(currentConfigs.size());
        for (Config currentConfig : currentConfigs) {
            currentConfigMap.put(currentConfig.getKey(), currentConfig);
        }
        Map<Integer, List<ConfigInstance>> currentConfigInstMap = new HashMap<Integer, List<ConfigInstance>>(
                currentConfigInsts.size());
        for (ConfigInstance currentConfigInst : currentConfigInsts) {
            List<ConfigInstance> instList = currentConfigInstMap.get(currentConfigInst.getConfigId());
            if (instList == null) {
                instList = new ArrayList<ConfigInstance>();
                currentConfigInstMap.put(currentConfigInst.getConfigId(), instList);
            }
            instList.add(currentConfigInst);
        }
        Set<String> currentConfigKeys = currentConfigMap.keySet();

        Set<String> notRemovedKeys = new HashSet<String>();
        Set<String> selectedKeys = null;
        if (keys != null) {
            selectedKeys = new HashSet<String>();
            for (String key : keys) {
                selectedKeys.add(key);
            }
        }
        //1. ????
        /* Notice:
         * ???????????
         * 
         */
        Collection<String> configNeedRemoveKeys = CollectionUtils.subtract(currentConfigKeys,
                configSnapshotKeys);
        notRemovedKeys.addAll(configNeedRemoveKeys);
        //      for (final String configNeedRemoveKey : configNeedRemoveKeys) {
        //         this.transactionTemplate.execute(new TransactionCallbackWithoutResult() {
        //            @Override
        //            protected void doInTransactionWithoutResult(TransactionStatus status) {
        //               Config configNeedRemove = currentConfigMap.get(configNeedRemoveKey);
        //               configService.deleteInstance(configNeedRemove.getId(), envId);
        //            }
        //         });
        //      }

        //2. ??????
        Collection<String> intersectionKeys = CollectionUtils.intersection(currentConfigKeys,
                configSnapshotKeys);
        for (String intersectionKey : intersectionKeys) {
            if (selectedKeys != null && !selectedKeys.contains(intersectionKey))
                continue;
            ConfigSnapshot configSnapshot = configSnapshotMap.get(intersectionKey);
            final Config currentConfig = currentConfigMap.get(intersectionKey);
            final List<ConfigInstanceSnapshot> snapshotInstList = configInstSnapshotMap
                    .get(configSnapshot.getConfigId());
            final List<ConfigInstance> currentInstList = currentConfigInstMap.get(currentConfig.getId());
            boolean snapshotNoInst = snapshotInstList == null || snapshotInstList.isEmpty();
            boolean currentNoInst = currentInstList == null || currentInstList.isEmpty();
            if (snapshotNoInst == true && currentNoInst == false) {
                notRemovedKeys.add(intersectionKey);
            } else if (snapshotNoInst == false && currentNoInst == true) {
                //??configinstanceregister server
                this.transactionTemplate.execute(new TransactionCallbackWithoutResult() {
                    @Override
                    protected void doInTransactionWithoutResult(TransactionStatus status) {
                        restoreConfigInstSnapshots(currentConfig.getId(), envId, snapshotInstList);
                    }
                });
            } else if (snapshotNoInst == false && currentNoInst == false) {
                Date modifyTime = modifyTimes.get(currentConfig.getId());
                Date recordModifyTime = configSnapshot.getValueModifyTime();
                if (modifyTime == null || recordModifyTime == null || !modifyTime.equals(recordModifyTime)) {
                    boolean onlyOneSnapshotInst = snapshotInstList.size() == 1;
                    boolean onlyOneCurrentInst = currentInstList.size() == 1;
                    if (onlyOneSnapshotInst && onlyOneCurrentInst) {
                        ConfigInstanceSnapshot snapshotInst = snapshotInstList.get(0);
                        ConfigInstance currentInst = currentInstList.get(0);
                        if (snapshotInst.getContext().equals(currentInst.getContext())
                                && snapshotInst.getValue().equals(currentInst.getValue())) {
                            continue;
                        }
                    }
                    this.transactionTemplate.execute(new TransactionCallbackWithoutResult() {
                        @Override
                        protected void doInTransactionWithoutResult(TransactionStatus status) {
                            configDao.deleteInstances(currentConfig.getId(), envId);
                            restoreConfigInstSnapshots(currentConfig.getId(), envId, snapshotInstList);
                        }
                    });
                }
            }
        }

        //3. ???
        Collection<String> configNeedAddKeys = CollectionUtils.subtract(configSnapshotKeys, currentConfigKeys);
        for (final String configNeedAddKey : configNeedAddKeys) {
            if (selectedKeys != null && !selectedKeys.contains(configNeedAddKey))
                continue;
            final ConfigSnapshot configSnapshot = configSnapshotMap.get(configNeedAddKey);
            final List<ConfigInstanceSnapshot> snapshotInstList = configInstSnapshotMap
                    .get(configSnapshot.getConfigId());
            if (snapshotInstList != null && !snapshotInstList.isEmpty()) {
                this.transactionTemplate.execute(new TransactionCallbackWithoutResult() {
                    @Override
                    protected void doInTransactionWithoutResult(TransactionStatus status) {
                        int configId = configService.createConfig(configSnapshot.toConfig());
                        restoreConfigInstSnapshots(configId, envId, snapshotInstList);
                    }
                });
            }
        }
        rollbackResult.setNotRemovedKeys(notRemovedKeys);
        return rollbackResult;
    } catch (RuntimeException e) {
        Project project = projectService.getProject(projectId);
        logger.error("rollback configs failed with[project=" + project.getName() + ", task="
                + snapshotSet.getTask() + "].", e);
        throw e;
    }
}

From source file:org.orcid.core.manager.impl.OrcidIndexManagerImpl.java

@Override
public void persistProfileInformationForIndexingIfNecessary(OrcidProfile orcidProfile) {
    String orcid = orcidProfile.getOrcidIdentifier().getPath();
    Date lastModifiedFromSolr = solrDao.retrieveLastModified(orcid);
    Date lastModifiedFromDb = orcidProfile.getOrcidHistory().getLastModifiedDate().getValue()
            .toGregorianCalendar().getTime();
    if (lastModifiedFromDb.equals(lastModifiedFromSolr)) {
        // Check if re-indexing
        IndexingStatus indexingStatus = profileDao.retrieveIndexingStatus(orcid);
        if (!IndexingStatus.REINDEX.equals(indexingStatus)) {
            // If not re-indexing then skip
            LOG.info("Index is already up to date for orcid: {}", orcid);
            return;
        }//from  w  ww  .ja  va2 s  .c  o m
    }
    persistProfileInformationForIndexing(orcidProfile);
}

From source file:DataPreProcess.ConvertedTrace.java

private void construct_Matrix_Phase() {
    long time_shift = 0;
    Date cali_st = null;// ww  w. jav a 2 s.  com
    Date pt_st = null;
    Date pt_ed = null;
    Date pri_st = null;
    Date pri_ed = null;
    Date sec_st = null;
    Date sec_ed = null;
    Date pst_sec_st = null;
    Date pst_sec_ed = null;
    //        Date pd_st = null;
    //        Date pd_ed = null;
    //Get all the date
    for (Phase ph : p) {
        if (pt.contains(ph.phaseName)) {
            cali_st = ph.start;
            pt_st = ph.start;
            pt_ed = ph.end;
        }
        if (pre_pri.contains(ph.phaseName)) { //merge preprimary to patient arrival
            pt_ed = ph.end;
        }
        if (pri.contains(ph.phaseName)) {
            pt_ed = ph.start;
            pri_st = ph.start;
            pri_ed = ph.end;
        }
        if (sec.contains(ph.phaseName)) {
            pri_ed = ph.start;
            sec_st = ph.start;
            sec_ed = ph.end;
        }
        if (pst_sec.contains(ph.phaseName)) {
            sec_ed = ph.start;
            pst_sec_st = ph.start;
            pst_sec_ed = ph.end;
        }
        //            if (pd.contains(ph.phaseName)) {
        //                pd_st = ph.start;
        //                pd_ed = ph.end;
        //            }
    }

    if (cali_st != null) {
        time_shift = cali_st.getTime();
    }

    //        Calibrate start time
    pt_st = new Date(pt_st.getTime() - time_shift);
    pt_ed = new Date(pt_ed.getTime() - time_shift);
    pri_st = new Date(pri_st.getTime() - time_shift);
    pri_ed = new Date(pri_ed.getTime() - time_shift);
    sec_st = new Date(sec_st.getTime() - time_shift);
    sec_ed = new Date(sec_ed.getTime() - time_shift);
    pst_sec_st = new Date(pst_sec_st.getTime() - time_shift);
    pst_sec_ed = new Date(pst_sec_ed.getTime() - time_shift);

    phase_percentage[0] = (double) (pt_ed.getTime() - pt_st.getTime());
    phase_percentage[1] = (double) (pri_ed.getTime() - pri_st.getTime());
    phase_percentage[2] = (double) (sec_ed.getTime() - sec_st.getTime());
    phase_percentage[3] = (double) (pst_sec_ed.getTime() - pst_sec_st.getTime());

    for (Activity ac : activities) {
        int start_index = 0;
        int end_index = 0;
        Date ac_st = ac.get_startTime();
        Date ac_end = ac.get_endTime();
        if (ac_st.after(pst_sec_ed)) {
            start_index = Length - 1;
            //wrong situation, start after end
        } else if (ac_st.after(pst_sec_st) || ac_st.equals(pst_sec_st)) {
            start_index = pt_arrival_length + Primary_length + Secondary_length
                    + (int) ((double) (ac_st.getTime() - pst_sec_st.getTime()) / phase_percentage[3]
                            * Pst_secondary_length);
        } else if (ac_st.after(sec_st) || ac_st.equals(sec_st)) {
            start_index = pt_arrival_length + Primary_length
                    + (int) ((double) (ac_st.getTime() - sec_st.getTime()) / phase_percentage[2]
                            * Secondary_length);
        } else if (ac_st.after(pri_st) || ac_st.equals(pri_st)) {
            start_index = pt_arrival_length + (int) ((double) (ac_st.getTime() - pri_st.getTime())
                    / phase_percentage[1] * Primary_length);
        } else if (ac_st.after(pt_st) || ac_st.equals(pt_st)) {
            start_index = (int) ((double) (ac_st.getTime() - pt_st.getTime()) / phase_percentage[0]
                    * pt_arrival_length);
        } else {
            start_index = 0;
        }

        if (ac_end.before(pt_st)) {
            end_index = 0;
            //wrong situation, end before start
        } else if (ac_end.before(pt_ed) || ac_end.equals(pt_ed)) {
            end_index = pt_arrival_length - (int) ((double) (pt_ed.getTime() - ac_end.getTime())
                    / phase_percentage[0] * pt_arrival_length);
        } else if (ac_end.before(pri_ed) || ac_end.equals(pri_ed)) {
            end_index = pt_arrival_length + Primary_length
                    - (int) ((double) (pri_ed.getTime() - ac_end.getTime()) / phase_percentage[1]
                            * Primary_length);
        } else if (ac_end.before(sec_ed) || ac_end.equals(sec_ed)) {
            end_index = pt_arrival_length + Primary_length + Secondary_length
                    - (int) ((double) (sec_ed.getTime() - ac_end.getTime()) / phase_percentage[2]
                            * Secondary_length);
        } else if (ac_end.before(pst_sec_ed) || ac_end.equals(pst_sec_ed)) {
            end_index = pt_arrival_length + Primary_length + Secondary_length + Pst_secondary_length
                    - (int) ((double) (pst_sec_ed.getTime() - ac_end.getTime()) / phase_percentage[3]
                            * Pst_secondary_length);
        } else {
            end_index = Length;
            //Patient departure, not included
        }
        end_index = end_index >= Length ? Length : end_index; // Avoid out of boundry

        //Set corresponding cells to 1
        int row_index = Activity_set.indexOf(ac.get_name());
        try {
            if (end_index < start_index) {
                System.out.println("Activity: " + ac.get_name() + " Index incorrect: " + " st:" + start_index
                        + " ed:" + end_index);
            } else {
                if (end_index == start_index && end_index < Length) {
                    end_index++;
                }
                fill_activity(row_index, start_index, end_index);
            }
        } catch (ArrayIndexOutOfBoundsException e) {
            System.out.println("Activity: " + ac.get_name() + " st:" + start_index + " ed:" + end_index
                    + " OutOfBounds!!!");
        }
        normalize_matrix_row();
    }

    double duration = pst_sec_ed.getTime() - pt_st.getTime();
    phase_percentage[0] /= duration;
    phase_percentage[1] /= duration;
    phase_percentage[2] /= duration;
    phase_percentage[3] /= duration;
}

From source file:org.kalypso.kalypsomodel1d2d.sim.RMA10ResultPage.java

@Override
public void createControl(final Composite parent) {
    final Composite composite = new Composite(parent, SWT.NONE);
    composite.setLayout(new GridLayout());

    /* Status composite */
    final Group statusGroup = new Group(composite, SWT.NONE);
    statusGroup.setLayout(new GridLayout());
    statusGroup.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    statusGroup.setText(Messages.getString("org.kalypso.kalypsomodel1d2d.sim.RMA10ResultPage.3")); //$NON-NLS-1$

    m_statusComp = new StatusComposite(statusGroup, StatusComposite.DETAILS);
    m_statusComp.setLayoutData(new GridData(SWT.FILL, SWT.LEFT, true, false));
    m_statusComp.setStatus(new Status(IStatus.INFO, KalypsoModel1D2DPlugin.PLUGIN_ID,
            Messages.getString("org.kalypso.kalypsomodel1d2d.sim.RMA10ResultPage.4"))); //$NON-NLS-1$

    /* Control flags */
    final Group tweakGroup = new Group(composite, SWT.NONE);
    tweakGroup.setLayout(new GridLayout());
    tweakGroup.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    tweakGroup.setText(Messages.getString("org.kalypso.kalypsomodel1d2d.sim.RMA10ResultPage.5")); //$NON-NLS-1$

    final IControlModel1D2D controlModel = m_resultManager.getControlModel();
    m_deleteAllResults = !controlModel.getRestart();

    final Button deleteAllCheck = new Button(tweakGroup, SWT.CHECK);
    deleteAllCheck.setText(Messages.getString("org.kalypso.kalypsomodel1d2d.sim.RMA10ResultPage.6")); //$NON-NLS-1$
    deleteAllCheck.setToolTipText(Messages.getString("org.kalypso.kalypsomodel1d2d.sim.RMA10ResultPage.7")); //$NON-NLS-1$
    deleteAllCheck.setSelection(m_deleteAllResults);
    deleteAllCheck.addSelectionListener(new SelectionAdapter() {
        @Override/*from w  ww. ja v  a2 s.c o m*/
        public void widgetSelected(final SelectionEvent e) {
            m_deleteAllResults = deleteAllCheck.getSelection();
        }
    });
    // If non-restart, always all results must be deleted.
    deleteAllCheck.setEnabled(!controlModel.getRestart());

    final Button evaluateFullCheck = new Button(tweakGroup, SWT.CHECK);
    evaluateFullCheck.setText(Messages.getString("org.kalypso.kalypsomodel1d2d.sim.RMA10ResultPage.18")); //$NON-NLS-1$
    evaluateFullCheck.setToolTipText(Messages.getString("org.kalypso.kalypsomodel1d2d.sim.RMA10ResultPage.19")); //$NON-NLS-1$
    evaluateFullCheck.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(final SelectionEvent e) {
            m_evaluateFullResults = evaluateFullCheck.getSelection();
        }
    });

    /* checklist with calculated steps to choose from */

    /* Result chooser */
    final Group resultChooserGroup = new Group(composite, SWT.NONE);
    resultChooserGroup.setLayout(new GridLayout());
    resultChooserGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    resultChooserGroup.setText(Messages.getString("org.kalypso.kalypsomodel1d2d.sim.RMA10ResultPage.8")); //$NON-NLS-1$

    final Composite resultChooserComp = new Composite(resultChooserGroup, SWT.BORDER);
    resultChooserComp.setLayout(new FillLayout(SWT.HORIZONTAL));
    resultChooserComp.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));

    final Table table = new Table(resultChooserComp, SWT.BORDER | SWT.CHECK);
    m_resultProcessViewer = new CheckboxTableViewer(table);
    m_resultProcessViewer.setContentProvider(new ArrayContentProvider());
    m_resultProcessViewer.setLabelProvider(new LabelProvider() {
        @Override
        public String getText(final Object element) {
            if (element instanceof Date) {
                final Date date = (Date) element;
                if (date.equals(MAXI_DATE))
                    return Messages.getString("org.kalypso.kalypsomodel1d2d.sim.RMA10ResultPage.9"); //$NON-NLS-1$
                else if (date.equals(STEADY_DATE))
                    return Messages.getString("org.kalypso.kalypsomodel1d2d.sim.RMA10ResultPage.10"); //$NON-NLS-1$

                return getTimeStepFormat().format(date);
            }

            return super.getText(element);
        }
    });

    try {
        final Date[] calculatedSteps = m_resultManager.findCalculatedSteps();
        m_resultProcessViewer.setInput(calculatedSteps);
        m_selection = calculatedSteps;
        m_resultManager.setStepsToProcess(m_selection);
    } catch (final IOException e) {
        e.printStackTrace();
    }
    getContainer().updateButtons();

    /* Info View for one result */
    final ResultInfoViewer infoViewer = new ResultInfoViewer(resultChooserComp, SWT.NONE, m_timeStepFormat);

    if (m_selection != null)
        m_resultProcessViewer.setCheckedElements(m_selection);

    m_resultProcessViewer.addSelectionChangedListener(new ISelectionChangedListener() {
        @Override
        public void selectionChanged(final SelectionChangedEvent event) {
            handleSelectionChanged((IStructuredSelection) event.getSelection(), infoViewer);
        }
    });

    m_resultProcessViewer.addCheckStateListener(new ICheckStateListener() {
        @Override
        public void checkStateChanged(final CheckStateChangedEvent event) {
            updateSelection();
        }
    });

    addSelectionButtons(m_resultProcessViewer, resultChooserGroup);

    setControl(composite);
}

From source file:com.liferay.portal.model.AddressModel.java

public void setCreateDate(Date createDate) {
    if (((createDate == null) && (_createDate != null)) || ((createDate != null) && (_createDate == null))
            || ((createDate != null) && (_createDate != null) && !createDate.equals(_createDate))) {
        _createDate = createDate;/* www. j a v a  2s  . c  o m*/
        setModified(true);
    }
}

From source file:com.autentia.tnt.jsf.schedule.renderer.ExternalActivityScheduleEntryRenderer.java

protected void renderCompactContent(FacesContext context, ResponseWriter writer, HtmlSchedule schedule,
        ScheduleDay day, ScheduleEntry entry, boolean selected) throws IOException {
    StringBuffer text = new StringBuffer();
    Date startTime = entry.getStartTime();

    if (day.getDayStart().after(entry.getStartTime())) {
        startTime = day.getDayStart();/*from  ww w.j  a v a  2 s. co m*/
    }

    Date endTime = entry.getEndTime();

    if (day.getDayEnd().before(entry.getEndTime())) {
        endTime = day.getDayEnd();
    }

    if (!entry.isAllDay()) {
        DateFormat format = DateFormat.getTimeInstance(DateFormat.SHORT);
        text.append(format.format(startTime));
        if (!startTime.equals(endTime)) {
            text.append("-");
            text.append(format.format(endTime));
        }
        text.append(": ");
    }
    text.append(StringUtils.abbreviate(entry.getTitle(), 20));

    writer.startElement(HTML.SPAN_ELEM, schedule);
    writer.writeAttribute(HTML.CLASS_ATTR, getStyleClass(schedule, "externalActivity"), null);

    writer.writeText(text.toString(), null);

    writer.endElement(HTML.SPAN_ELEM);

}