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:gov.utah.dts.sdc.actions.CommercialStudentSearchAction.java

private Student getDbStudent(Student st, Date webDob) throws Exception {

    Student retObj = null;/*w ww.j a  va2s  .  c o m*/
    List list = getStudentService().getStudentList(st);
    for (int i = 0; i < list.size(); i++) {
        Student dbStudent = (Student) list.get(i);
        log.debug("webdob = " + webDob + " dob = " + dbStudent.getDob());
        if (webDob != null) {
            if (webDob.equals(dbStudent.getDob())) {
                retObj = dbStudent;
                break;
            }
        }
    }

    return retObj;
}

From source file:net.chaosserver.timelord.data.TimelordTask.java

/**
 * Gets the TaskDay object for the date to find.  If the create
 * flag is true, than a new object will be created if there is no
 * existing one.//  w  w w .j  a  v a2 s  .  c  o  m
 *
 * @param dateToFind the date to retrieve the task date object for.
 * @param create should the object be created if one doesn't exist
 * @return the TaskDate for the day, or a null if create is false
 *         and no object currently exists
 */
public synchronized TimelordTaskDay getTaskDay(Date dateToFind, boolean create) {
    if (log.isDebugEnabled()) {
        log.debug("Searching [" + getTaskName() + "] for date of [" + dateToFind + "]");
    }

    TimelordTaskDay timelordTaskDay = null;

    Iterator<TimelordTaskDay> taskDayListIterator = getTaskDayList().iterator();

    while ((timelordTaskDay == null) && taskDayListIterator.hasNext()) {
        TimelordTaskDay tempTimelordTaskDay = (TimelordTaskDay) taskDayListIterator.next();

        if (log.isDebugEnabled()) {
            log.debug("Testing tempTimelordTaskDay.getDate [" + tempTimelordTaskDay.getDate()
                    + "] againt dateToFind of [" + dateToFind + "]");
        }

        if (dateToFind.equals(tempTimelordTaskDay.getDate())) {
            timelordTaskDay = tempTimelordTaskDay;
        } else if (dateToFind.after(tempTimelordTaskDay.getDate())) {
            // If the date to find is after the date we want, then we are
            // DONE.
            break;
        }
    }

    if ((timelordTaskDay == null) && create) {
        if (log.isDebugEnabled()) {
            log.debug("Creating new TimelordTaskDay for [" + dateToFind + "]");
        }

        timelordTaskDay = add(dateToFind);
    }

    return timelordTaskDay;
}

From source file:edu.northwestern.bioinformatics.studycalendar.service.SubjectService.java

private List<ScheduledActivity> getPotentialUpcomingEvents(ScheduledCalendar calendar, Date offStudyDate) {
    List<ScheduledActivity> upcomingScheduledActivities = new ArrayList<ScheduledActivity>();
    for (ScheduledStudySegment studySegment : calendar.getScheduledStudySegments()) {
        if (!studySegment.isComplete()) {
            Map<Date, List<ScheduledActivity>> eventsByDate = studySegment.getActivitiesByDate();
            for (Date date : eventsByDate.keySet()) {
                List<ScheduledActivity> events = eventsByDate.get(date);
                for (ScheduledActivity event : events) {
                    if ((offStudyDate.before(event.getActualDate())
                            || offStudyDate.equals(event.getActualDate()))
                            && (ScheduledActivityMode.SCHEDULED == event.getCurrentState().getMode()
                                    || ScheduledActivityMode.CONDITIONAL == event.getCurrentState()
                                            .getMode())) {
                        upcomingScheduledActivities.add(event);
                    }// www.  j av a  2 s.  co m
                }
            }
        }
    }
    return upcomingScheduledActivities;
}

From source file:org.oscarehr.ws.rest.NotesService.java

@POST
@Path("/{demographicNo}/save")
@Consumes("application/json")
@Produces("application/json")
public NoteTo1 saveNote(@PathParam("demographicNo") Integer demographicNo, NoteTo1 note) throws Exception {
    logger.debug("saveNote " + note);
    LoggedInInfo loggedInInfo = getLoggedInInfo(); //LoggedInInfo.loggedInInfo.get();
    String providerNo = loggedInInfo.getLoggedInProviderNo();
    Provider provider = loggedInInfo.getLoggedInProvider();
    String userName = provider != null ? provider.getFullName() : "";

    String demo = "" + demographicNo;

    CaseManagementNote caseMangementNote = new CaseManagementNote();

    caseMangementNote.setDemographic_no(demo);
    caseMangementNote.setProvider(provider);
    caseMangementNote.setProviderNo(providerNo);

    if (note.getUuid() != null && !note.getUuid().trim().equals("")) {
        caseMangementNote.setUuid(note.getUuid());
    }/* www  .j a  v a2 s  . c  o  m*/

    String noteTxt = note.getNote();
    noteTxt = org.apache.commons.lang.StringUtils.trimToNull(noteTxt);
    if (noteTxt == null || noteTxt.equals(""))
        return null;

    caseMangementNote.setNote(noteTxt);

    CaseManagementCPP cpp = this.caseManagementMgr.getCPP(demo);
    if (cpp == null) {
        cpp = new CaseManagementCPP();
        cpp.setDemographic_no(demo);
    }
    logger.debug("enc TYPE " + note.getEncounterType());
    caseMangementNote.setEncounter_type(note.getEncounterType());

    //caseMangementNote.setHourOfEncounterTime(note.getEncounterTime());
    logger.debug("this is what the encounter time was " + note.getEncounterTime());
    /*String hourOfEncounterTime = request.getParameter("hourOfEncounterTime");
    if (hourOfEncounterTime != null && hourOfEncounterTime != "") {
       note.setHourOfEncounterTime(Integer.valueOf(hourOfEncounterTime));
    }
            
    String minuteOfEncounterTime = request.getParameter("minuteOfEncounterTime");
    if (minuteOfEncounterTime != null && minuteOfEncounterTime != "") {
       note.setMinuteOfEncounterTime(Integer.valueOf(minuteOfEncounterTime));
    }*/

    logger.debug("this is what the encounter time was " + note.getEncounterTransportationTime());
    /*
    String hourOfEncTransportationTime = request.getParameter("hourOfEncTransportationTime");
    if (hourOfEncTransportationTime != null && hourOfEncTransportationTime != "") {
       note.setHourOfEncTransportationTime(Integer.valueOf(hourOfEncTransportationTime));
    }
            
    String minuteOfEncTransportationTime = request.getParameter("minuteOfEncTransportationTime");
    if (minuteOfEncTransportationTime != null && minuteOfEncTransportationTime != "") {
       note.setMinuteOfEncTransportationTime(Integer.valueOf(minuteOfEncTransportationTime));
    }
    */
    //Need to check some how that if a note is signed that it must stay signed, currently this is done in the interface where the save button is not available.
    if (note.getIsSigned()) {
        caseMangementNote.setSigning_provider_no(providerNo);
        caseMangementNote.setSigned(true);
    } else {
        caseMangementNote.setSigning_provider_no("");
        caseMangementNote.setSigned(false);
    }

    caseMangementNote.setProviderNo(providerNo);
    if (provider != null)
        caseMangementNote.setProvider(provider);

    //note.getPro
    String programIdString = getProgram(loggedInInfo, providerNo); //might not to convert it.
    Integer programId = null;
    try {
        programId = Integer.parseInt(programIdString);
    } catch (Exception e) {
        logger.warn("Error parsing programId:" + programIdString, e);
    }
    caseMangementNote.setProgram_no(programIdString);

    // get the checked issue save into note 
    // this goes into the database casemgmt_issue table
    List<CaseManagementIssue> issuelist = new ArrayList<CaseManagementIssue>();

    //CheckBoxBean[] checkedlist = sessionFrm.getIssueCheckList();

    // this gets attached to the CaseManagementNote object
    Set<CaseManagementIssue> issueset = new HashSet<CaseManagementIssue>();
    // wherever this is populated, it's not here...
    Set<CaseManagementNote> noteSet = new HashSet<CaseManagementNote>();
    String ongoing = new String();
    //ongoing = saveCheckedIssues_newCme(request, demo, note, issuelist, checkedlist, issueset, noteSet, ongoing);

    caseMangementNote.setIssues(issueset);

    // remove signature and the related issues from note 
    String noteString = note.getNote();
    // noteString = removeSignature(noteString);
    // noteString = removeCurrentIssue(noteString);
    caseMangementNote.setNote(noteString);

    /* Not sure how to handle this
    // add issues into notes 
    String includeIssue = request.getParameter("includeIssue");
    if (includeIssue == null || !includeIssue.equals("on")) {
       // set includeissue in note 
       note.setIncludeissue(false);
       sessionFrm.setIncludeIssue("off");
    } else {
       note.setIncludeissue(true);
       // add the related issues to note
            
       String issueString = new String();
       issueString = createIssueString(issueset);
       // insert the string before signiture
            
       int index = noteString.indexOf("\n[[");
       if (index >= 0) {
    String begString = noteString.substring(0, index);
    String endString = noteString.substring(index + 1);
    note.setNote(begString + issueString + endString);
       } else {
    note.setNote(noteString + issueString);
       }
    }
    */

    // update appointment and add verify message to note if verified
    boolean verify = false;
    if (note.getIsVerified()) {
        verify = true;
    }

    // update password
    /*
    String passwd = cform.getCaseNote().getPassword();
    if (passwd != null && passwd.trim().length() > 0) {
       note.setPassword(passwd);
       note.setLocked(true);
    }
     */
    Date now = new Date();

    Date observationDate = note.getObservationDate();
    if (observationDate != null && !observationDate.equals("")) {
        if (observationDate.getTime() > now.getTime()) {
            //request.setAttribute("DateError", props.getString("oscarEncounter.futureDate.Msg"));
            caseMangementNote.setObservation_date(now);
        } else {
            caseMangementNote.setObservation_date(observationDate);
        }
    } else if (note.getObservationDate() == null) {
        caseMangementNote.setObservation_date(now);
    }

    caseMangementNote.setUpdate_date(now);

    /* Currently not available from this method
    // Checks whether the user can set the program via the UI - if so, make sure that they can't screw it up if they do
    if (OscarProperties.getInstance().getBooleanProperty("note_program_ui_enabled", "true")) {
       String noteProgramNo = request.getParameter("_note_program_no");
       String noteRoleId = request.getParameter("_note_role_id");
            
       if (noteProgramNo != null && noteRoleId != null && noteProgramNo.trim().length() > 0 && noteRoleId.trim().length() > 0) {
          if (noteProgramNo.equalsIgnoreCase("-2") || noteRoleId.equalsIgnoreCase("-2")) {
             throw new Exception("Patient is not admitted to any programs user has access to. [roleId=-2, programNo=-2]");
          } else if (!noteProgramNo.equalsIgnoreCase("-1") && !noteRoleId.equalsIgnoreCase("-1")) {
             note.setProgram_no(noteProgramNo);
             note.setReporter_caisi_role(noteRoleId);
          }
       } else {
                throw new Exception("Missing role id or program number. [roleId=" + noteRoleId + ", programNo=" + noteProgramNo + "]");
       }
    }
        */

    //if (note.getAppointmentNo() != null) {
    caseMangementNote.setAppointmentNo(note.getAppointmentNo());
    //}

    // Save annotation 

    CaseManagementNote annotationNote = null;// (CaseManagementNote) session.getAttribute(attrib_name);

    //String ongoing = null; // figure out this
    String lastSavedNoteString = null;
    String user = loggedInInfo.getLoggedInProvider().getProviderNo();
    String remoteAddr = ""; // Not sure how to get this   
    caseMangementNote = caseManagementMgr.saveCaseManagementNote(caseMangementNote, issuelist, cpp, ongoing,
            verify, loggedInInfo.getLocale(), now, annotationNote, userName, user, remoteAddr,
            lastSavedNoteString);

    caseManagementMgr.getEditors(caseMangementNote);

    note.setNoteId(Integer.parseInt("" + caseMangementNote.getId()));
    note.setUuid(caseMangementNote.getUuid());
    note.setUpdateDate(caseMangementNote.getUpdate_date());
    note.setObservationDate(caseMangementNote.getObservation_date());
    logger.error("note should return like this " + note.getNote());
    return note;

    /*
    //update lock to new note id
    casemgmtNoteLockSession.setNoteId(note.getId());
    logger.info("UPDATING NOTE ID in LOCK");
    casemgmtNoteLockDao.merge(casemgmtNoteLockSession);
    session.setAttribute("casemgmtNoteLock"+demo, casemgmtNoteLockSession);   
    */

    /*
    String sessionFrmName = "caseManagementEntryForm" + demo;
    CaseManagementEntryFormBean sessionFrm = (CaseManagementEntryFormBean) session.getAttribute(sessionFrmName);
            
    CasemgmtNoteLock casemgmtNoteLockSession = (CasemgmtNoteLock)session.getAttribute("casemgmtNoteLock"+demo);            
            
    try {
               
       if(casemgmtNoteLockSession == null) {
    throw new Exception("SESSION CASEMANAGEMENT NOTE LOCK OBJECT IS NULL");
       }
               
       CasemgmtNoteLock casemgmtNoteLock = casemgmtNoteLockDao.find(casemgmtNoteLockSession.getId());
       //if other window has acquired lock we reject save                           
       if( !casemgmtNoteLock.getSessionId().equals(casemgmtNoteLockSession.getSessionId()) || !request.getRequestedSessionId().equals(casemgmtNoteLockSession.getSessionId()) ) {
    logger.info("DO NOT HAVE LOCK FOR " + demo + " PROVIDER " + providerNo + " CONTINUE SAVING LOCAL SESSION " + request.getRequestedSessionId() + " LOCAL IP " + request.getRemoteAddr() + " LOCK SESSION " + casemgmtNoteLockSession.getSessionId() + " LOCK IP " + casemgmtNoteLockSession.getIpAddress());
    return -1L;
       }
    }
    catch(Exception e ) {
       //Exception thrown if other window has saved and exited so lock is gone
       logger.error("Lock not found for " + demo + " provider " + providerNo + " IP " + request.getRemoteAddr(), e);
       return -1L;
    }
    String lastSavedNoteString = (String) session.getAttribute("lastSavedNoteString");
            
    String strBeanName = "casemgmt_oscar_bean" + demo;
    EctSessionBean sessionBean = (EctSessionBean) session.getAttribute(strBeanName);
            
    return note.getId();
    */

}

From source file:com.mobileman.projecth.business.UserServiceTest.java

/**
 * /*ww  w.j  a  v  a 2 s.com*/
 * @throws Exception
 */
@Test
public void incrementNumberOfLogins() throws Exception {

    User user = userService.login("sysuser3", "54321");
    assertNotNull(user);

    int oldLoginsCount = user.getLoginsCount();
    Date oldLastLoginDate = user.getLastLogin();
    Thread.sleep(500);

    userService.incrementNumberOfLogins(user.getId());

    user = userService.findById(user.getId());
    assertEquals(oldLoginsCount + 1, user.getLoginsCount());
    assertFalse(oldLastLoginDate.equals(user.getLastLogin()));
}

From source file:com.openddal.test.BaseTestCase.java

/**
 * Check if two values are equal, and if not throw an exception.
 *
 * @param expected the expected value/*from   ww w .  j  a v  a  2 s .  c  o m*/
 * @param actual the actual value
 * @throws AssertionError if the values are not equal
 */
public void assertEquals(java.util.Date expected, java.util.Date actual) {
    if (expected != actual && !expected.equals(actual)) {
        DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
        SimpleTimeZone gmt = new SimpleTimeZone(0, "Z");
        df.setTimeZone(gmt);
        fail("Expected: " + df.format(expected) + " actual: " + df.format(actual));
    }
}

From source file:uk.ac.soton.itinnovation.ecc.service.utils.ExplorerDemoData.java

private EccINTRATSeries createHiliteSeries(String newKey, EccINTRATSeries srcSeries,
        ArrayList<EccActivity> actList) {
    // Copy source series data
    ArrayList<EccMeasurement> targMeasures = new ArrayList<>();
    for (EccMeasurement srcM : srcSeries.getValues()) {
        EccMeasurement targM = new EccMeasurement(srcM);
        targMeasures.add(targM);//www  .j av a  2 s.  c  om
    }

    // Run through list making null those measurements that match within time slices
    for (int i = 0; i < targMeasures.size() - 1; ++i) {
        Date m1Start = targMeasures.get(i).getTimestamp();
        Date m2Start = targMeasures.get(i + 1).getTimestamp();

        // See if it falls within activity set
        boolean makeNull = true;

        for (EccActivity act : actList) {
            Date actStamp = act.getStartTime();

            // If measurement data within an activity range
            if ((actStamp.equals(m1Start) || actStamp.after(m1Start)) && actStamp.before(m2Start))
                makeNull = false;
        }

        // Make measurement null if not in activity ranges
        if (makeNull)
            targMeasures.get(i).setValue(null);
    }

    // Always make last measurement null
    targMeasures.get(targMeasures.size() - 1).setValue(null);

    return new EccINTRATSeries(newKey, true, targMeasures);
}

From source file:com.virtusa.akura.reporting.controller.PerDayStaffCategoryWiseAttendanceController.java

/**
 * get present staff list with half day leave reason if any.
 *
 * @param presentStaffList - present staff list
 * @param dateConsider - date of the report .
 * @return map of staff/*  w  w  w.j a v a  2s  .c om*/
 * @throws AkuraAppException throw exception if occur.
 */
private Map<Staff, String> getPresentStaffListWithLeaveReason(List<Staff> presentStaffList, Date dateConsider)
        throws AkuraAppException {

    // create an present map for staffs with half day leave reason.

    Map<Staff, String> presentMap = new LinkedHashMap<Staff, String>();
    // Map<Staff, String> presentMap = new TreeMap<Staff, String>();
    Date attDate = dateConsider;

    if (!presentStaffList.isEmpty()) {

        for (Staff staff : presentStaffList) {
            String leaveDayType = null;
            List<StaffLeave> staffLeaveList = staffService.getStaffLeaveListByDatePeriodAndStaffId(attDate,
                    attDate, staff.getStaffId());

            if (!staffLeaveList.isEmpty()) {

                for (StaffLeave sl : staffLeaveList) {

                    Date getFromDate = DateUtil.getParseDate(sl.getFromDate().toString());
                    Date getToDate = DateUtil.getParseDate(sl.getToDate().toString());

                    if (getFromDate.before(attDate) && getToDate.after(attDate)) {

                        if (sl.getStaffLeaveStatusId().intValue() == 1) {
                            leaveDayType = sl.getDateType();
                        }

                    } else if (getFromDate.equals(attDate) || getToDate.equals(attDate)) {
                        if (sl.getStaffLeaveStatusId().intValue() == 1) {
                            leaveDayType = sl.getDateType();
                        }
                    }
                }
            }

            presentMap.put(staff, leaveDayType);

        }

    }
    return presentMap;

}

From source file:org.eclipse.smarthome.core.scheduler.CronExpression.java

@Override
public boolean isSatisfiedBy(Date date) {
    Calendar testDateCal = Calendar.getInstance(getTimeZone());
    testDateCal.setTime(date);//ww  w. java 2  s.c om
    testDateCal.set(Calendar.MILLISECOND, 0);
    Date originalDate = testDateCal.getTime();

    testDateCal.add(Calendar.SECOND, -1);

    Date timeAfter = getTimeAfter(testDateCal.getTime());

    return ((timeAfter != null) && (timeAfter.equals(originalDate)));
}

From source file:org.mifos.application.importexport.xls.XlsClientsImporter.java

private void validateDuplicateCustomers(final ClientCreationDetail client,
        final List<ImportedClientDetail> importedClients) throws RowException {
    final Date dob = client.getDateOfBirth();
    final String clientName = client.getClientName();

    for (ImportedClientDetail importedClient : importedClients) {
        final Date otherDob = importedClient.getClientCreationDetail().getDateOfBirth();
        final String otherName = importedClient.getClientCreationDetail().getClientName();

        if (dob.equals(otherDob) && clientName.equals(otherName)) {
            throw new RowException(getMessage(XlsMessageConstants.DUPLICATE_CLIENT_ERROR));
        }//from   w  w w .  j  a  va  2  s . com
    }
}