Example usage for java.util Date compareTo

List of usage examples for java.util Date compareTo

Introduction

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

Prototype

public int compareTo(Date anotherDate) 

Source Link

Document

Compares two Dates for ordering.

Usage

From source file:org.openmrs.module.chica.hl7.mckesson.HL7SocketHandler.java

/**
 * Adds new address and sets most recent address to preferred based on
 * encounter time./*from  ww w .ja  v a2 s .  c  o m*/
 * 
 * @param currentPatient
 * @param hl7Patient
 * @param encounterDate
 * @should set latest address to preferred and add to addresses
 */
public void addAddress(Patient currentPatient, Patient newPatient, Date encounterDate) {

    PersonAddress newAddress = newPatient.getPersonAddress();

    try {
        if (newAddress == null || (StringUtils.isBlank(newAddress.getAddress1())
                && StringUtils.isBlank(newAddress.getAddress2())
                && StringUtils.isBlank(newAddress.getCityVillage())
                && StringUtils.isBlank(newAddress.getCountry())
                && StringUtils.isBlank(newAddress.getPostalCode())
                && StringUtils.isBlank(newAddress.getCountyDistrict())
                && StringUtils.isBlank(newAddress.getStateProvince()))) {
            return;
        }

        boolean found = false;

        for (PersonAddress pa : currentPatient.getAddresses()) {
            if (!found && pa.equalsContent(newAddress)) {
                pa.setDateCreated(encounterDate);
                found = true;
                break;
            }
        }

        if (!found) {
            PersonAddress address = newPatient.getPersonAddress();
            if (address.getUuid() == null) {
                UUID uuid = UUID.randomUUID();
                address.setUuid(uuid.toString());
            }
            address.setDateCreated(new Date()); // CHICA-1157 Change the create date to current time so that the address can be updated if we receive an A10 then A04 with two different values 
            currentPatient.addAddress(address);
        }

        // reset all addresses preferred status
        Set<PersonAddress> addresses = currentPatient.getAddresses();
        for (PersonAddress address : addresses) {
            address.setPreferred(false);
        }

        // Sort the list of names based on date
        List<PersonAddress> addressList = new ArrayList<PersonAddress>(addresses);

        Collections.sort(addressList, new Comparator<PersonAddress>() {
            public int compare(PersonAddress a1, PersonAddress a2) {
                Date date1 = a1.getDateCreated();
                Date date2 = a2.getDateCreated();
                return date2.compareTo(date1);
            }
        });

        if (addressList.size() > 0 && addressList.get(0) != null) {
            // set latest to preferred
            addressList.get(0).setPreferred(true);
            Set<PersonAddress> addressSet = new TreeSet<PersonAddress>(addressList);
            if (addressSet.size() > 0) {
                currentPatient.getAddresses().clear();
                currentPatient.getAddresses().addAll(addressSet);
            }

        }
    } catch (Exception e) {
        log.error("Error adding addresses to patient MRN: " + newPatient.getPatientIdentifier(), e);

    }

}

From source file:org.openmrs.module.chica.hl7.mckesson.HL7SocketHandler.java

/**
 * Adds new name and sets most recent name to preferred. If the hl7 name
 * already exists the date created is updated to the encounter date. When
 * sorted the name with the latest date will be set as the preferred name
 * /*w  w  w  . j a  v a2s.com*/
 * @param currentPatient
 * @param hl7Patient
 * @param encounterDate
 * @should update date created if name already exists
 */
void addName(Patient currentPatient, Patient newPatient, Date encounterDate) {

    /*
     * Condition where newest hl7 name matches an older existing name ( not
     * currently the preferred name). OpenMRS equality checks will detect it
     * as equal and not add the name in addName(). So, that name will never
     * have an updated date, and will not get set as the preferred name.
     * Then, the wrong name will be displayed on the form.
     */
    try {
        PersonName newName = newPatient.getPersonName();
        if (newName == null || (StringUtils.isBlank(newName.getFamilyName())
                && StringUtils.isBlank(newName.getMiddleName()) && StringUtils.isBlank(newName.getGivenName())
                && StringUtils.isBlank(newName.getFamilyName2()) && StringUtils.isBlank(newName.getFullName())
                && StringUtils.isBlank(newName.getPrefix())
                && StringUtils.isBlank(newName.getFamilyNamePrefix())
                && StringUtils.isBlank(newName.getFamilyNameSuffix()))) {
            return;
        }

        boolean found = false;

        for (PersonName pn : currentPatient.getNames()) {
            if (!found && pn.equalsContent(newName)) {
                pn.setDateCreated(encounterDate);
                found = true;
                break;
            }

        }

        if (!found) {
            if (newName.getUuid() == null) {
                UUID uuid = UUID.randomUUID();
                newName.setUuid(uuid.toString());
            }

            currentPatient.addName(newName);
        }

        Set<PersonName> names = currentPatient.getNames();

        // reset all addresses preferred status
        for (PersonName name : names) {
            name.setPreferred(false);
        }

        // Sort the list of names based on date
        List<PersonName> nameList = new ArrayList<PersonName>(names);

        Collections.sort(nameList, new Comparator<PersonName>() {
            public int compare(PersonName n1, PersonName n2) {
                Date date1 = n1.getDateCreated();
                Date date2 = n2.getDateCreated();
                return date2.compareTo(date1);
            }
        });

        if (nameList.size() > 0 && nameList.get(0) != null) {
            // set latest to preferred
            nameList.get(0).setPreferred(true);
            Set<PersonName> nameSet = new TreeSet<PersonName>(nameList);
            if (nameSet.size() > 0) {
                currentPatient.getNames().clear();
                currentPatient.getNames().addAll(nameSet);
            }
        }

    } catch (Exception e) {
        log.error("Error updating patient name. MRN: " + newPatient.getPatientIdentifier(), e);
    }
}

From source file:org.geoserver.importer.Importer.java

public Iterator<ImportContext> getAllContextsByUpdated() {
    try {// ww  w.  j a va2 s .co m
        return contextStore.iterator("updated");
    } catch (UnsupportedOperationException e) {
        //fallback
        TreeSet sorted = new TreeSet<ImportContext>(new Comparator<ImportContext>() {
            @Override
            public int compare(ImportContext o1, ImportContext o2) {
                Date d1 = o1.getUpdated();
                Date d2 = o2.getUpdated();
                return -1 * d1.compareTo(d2);
            }
        });
        Iterators.addAll(sorted, contextStore.iterator());
        return sorted.iterator();
    }
}

From source file:org.finra.herd.service.impl.BusinessObjectDataInitiateDestroyHelperServiceImpl.java

/**
 * Validate that business object data is supported by the business object data destroy feature.
 *
 * @param businessObjectDataEntity the business object data entity
 * @param businessObjectDataKey the business object data key
 *//*from   w  w w  . ja va 2  s . c o m*/
void validateBusinessObjectData(BusinessObjectDataEntity businessObjectDataEntity,
        BusinessObjectDataKey businessObjectDataKey) {
    // Get business object format for this business object data.
    BusinessObjectFormatEntity businessObjectFormatEntity = businessObjectDataEntity.getBusinessObjectFormat();

    // Create a version-less key for the business object format.
    BusinessObjectFormatKey businessObjectFormatKey = new BusinessObjectFormatKey(
            businessObjectDataKey.getNamespace(), businessObjectDataKey.getBusinessObjectDefinitionName(),
            businessObjectDataKey.getBusinessObjectFormatUsage(),
            businessObjectDataKey.getBusinessObjectFormatFileType(), null);

    // Get the latest version of the format to retrieve retention information.
    BusinessObjectFormatEntity latestVersionBusinessObjectFormatEntity = businessObjectFormatEntity
            .getLatestVersion() ? businessObjectFormatEntity
                    : businessObjectFormatDao.getBusinessObjectFormatByAltKey(businessObjectFormatKey);

    // Get retention information.
    String retentionType = latestVersionBusinessObjectFormatEntity.getRetentionType() != null
            ? latestVersionBusinessObjectFormatEntity.getRetentionType().getCode()
            : null;
    Integer retentionPeriodInDays = latestVersionBusinessObjectFormatEntity.getRetentionPeriodInDays();

    // Get the current timestamp from the database.
    Timestamp currentTimestamp = herdDao.getCurrentTimestamp();

    // Validate that retention information is specified for this business object format.
    if (retentionType != null) {
        switch (retentionType) {
        case RetentionTypeEntity.PARTITION_VALUE:
            Assert.notNull(retentionPeriodInDays,
                    String.format("Retention period in days must be specified for %s retention type.",
                            RetentionTypeEntity.PARTITION_VALUE));
            Assert.isTrue(retentionPeriodInDays > 0,
                    String.format(
                            "A positive retention period in days must be specified for %s retention type.",
                            RetentionTypeEntity.PARTITION_VALUE));

            // Try to convert business object data primary partition value to a timestamp.
            // If conversion is not successful, the method returns a null value.
            Date primaryPartitionValue = businessObjectDataHelper
                    .getDateFromString(businessObjectDataEntity.getPartitionValue());

            // If primary partition values is not a date, this business object data is not supported by the business object data destroy feature.
            if (primaryPartitionValue == null) {
                throw new IllegalArgumentException(String.format(
                        "Primary partition value \"%s\" cannot get converted to a valid date. Business object data: {%s}",
                        businessObjectDataEntity.getPartitionValue(),
                        businessObjectDataHelper.businessObjectDataKeyToString(businessObjectDataKey)));
            }

            // Compute the relative primary partition value threshold date based on the current timestamp and retention period value.
            Date primaryPartitionValueThreshold = new Date(
                    HerdDateUtils.addDays(currentTimestamp, -retentionPeriodInDays).getTime());

            // Validate that this business object data has it's primary partition value before or equal to the threshold date.
            if (primaryPartitionValue.compareTo(primaryPartitionValueThreshold) > 0) {
                throw new IllegalArgumentException(String.format(
                        "Business object data fails retention threshold check for retention type \"%s\" with retention period of %d days. "
                                + "Business object data: {%s}",
                        retentionType, retentionPeriodInDays,
                        businessObjectDataHelper.businessObjectDataKeyToString(businessObjectDataKey)));
            }
            break;
        case RetentionTypeEntity.BDATA_RETENTION_DATE:
            // Retention period in days value must only be specified for PARTITION_VALUE retention type.
            Assert.isNull(retentionPeriodInDays, String.format(
                    "A retention period in days cannot be specified for %s retention type.", retentionType));

            // Validate that the retention information is specified for business object data with retention type as BDATA_RETENTION_DATE.
            Assert.notNull(businessObjectDataEntity.getRetentionExpiration(), String.format(
                    "Retention information with retention type %s must be specified for the Business Object Data: {%s}",
                    retentionType,
                    businessObjectDataHelper.businessObjectDataKeyToString(businessObjectDataKey)));

            // Validate that the business object data retention expiration date is in the past.
            if (!(businessObjectDataEntity.getRetentionExpiration().before(currentTimestamp))) {
                throw new IllegalArgumentException(String.format(
                        "Business object data fails retention threshold check for retention type \"%s\" with retention expiration date %s. "
                                + "Business object data: {%s}",
                        retentionType, businessObjectDataEntity.getRetentionExpiration(),
                        businessObjectDataHelper.businessObjectDataKeyToString(businessObjectDataKey)));
            }
            break;
        default:
            throw new IllegalArgumentException(String.format(
                    "Retention type \"%s\" is not supported by the business object data destroy feature. Business object format: {%s}",
                    retentionType,
                    businessObjectFormatHelper.businessObjectFormatKeyToString(businessObjectFormatKey)));
        }
    } else {
        throw new IllegalArgumentException(String.format(
                "Retention information is not configured for the business object format. Business object format: {%s}",
                businessObjectFormatHelper.businessObjectFormatKeyToString(businessObjectFormatKey)));
    }
}

From source file:com.nec.harvest.controller.KoguchiController.java

/**
 * Load koguchi page with parameters organization code and current date
 * /*from ww  w.j  a  v  a  2 s.c om*/
 * @param orgCode
 *            Organization code on request path
 * @param monthly
 *            Current business day on request path
 * @param model
 *            Model to update and return to view
 * @param businessDay
 *            Business day on session
 * @param orgCodeFromSession
 *            Organization code on session
 * @return Logic page view
 */
@RequestMapping(value = "/{orgCode}/{monthly}", method = RequestMethod.GET)
public String render(@SessionAttribute(Constants.SESS_ORGANIZATION_CODE) String userOrgCode,
        @SessionAttribute(Constants.SESS_BUSINESS_DAY) Date businessDay, @PathVariable String proGNo,
        @PathVariable String orgCode, @PathVariable @DateTimeFormat(pattern = "yyyyMM") Date monthly,
        final Model model) {
    logger.info("Koguchi page view rendering...");

    //
    model.addAttribute(PRINTABLE, true);
    model.addAttribute(PROCESSING_MONTH, monthly);

    try {
        // Get petty cash data
        List<PettyCash> pettyCashes = pettyCashService.findByOrgCodeAndBusinessDay(userOrgCode, monthly);
        model.addAttribute(PETTY_CASH_LIST, pettyCashes);
        if (pettyCashes == null || pettyCashes.size() == 0) {
            model.addAttribute(ERROR, false);
            model.addAttribute(ERROR_MESSAGE, MessageHelper.get(MsgConstants.CM_QRY_M01));
        }
    } catch (IllegalArgumentException ex) {
        logger.warn(ex.getMessage());
    } catch (ServiceException ex) {
        logger.error(ex.getMessage(), ex);

        // ???????????
        model.addAttribute(ERROR, true);
        model.addAttribute(ERROR_MESSAGE, getSystemError());
        return getViewName();
    }

    try {

        // Check next and previous month is available            
        Date previousMonth = DateUtil.monthsToSubtract(businessDay, 12);
        Date nextMonth = DateUtil.monthsToSubtract(businessDay, 1);
        if (monthly.compareTo(previousMonth) > 0) {
            model.addAttribute(PREVIOUS_MONTH, DateUtil.monthsToSubtract(monthly, 1));
        }

        if (monthly.compareTo(nextMonth) <= 0) {
            model.addAttribute(NEXT_MONTH, DateUtil.monthsToAdd(monthly, 1));
        }

    } catch (IllegalArgumentException ex) {
        logger.warn(ex.getMessage());
    }

    try {
        // Get small category data
        List<SmallCategory> smallCategories = smallCategoryService.findAll();
        model.addAttribute(SMALL_CATEGORY_LIST, smallCategories);
    } catch (IllegalArgumentException ex) {
        logger.warn(ex.getMessage());
    } catch (ServiceException ex) {
        logger.error(ex.getMessage(), ex);

        // ???????????
        model.addAttribute(ERROR, true);
        model.addAttribute(ERROR_MESSAGE, getSystemError());
        return getViewName();
    }

    try {
        // Get default total amount
        Organization orgObj = organizationService.findByOrgCode(orgCode);
        if (logger.isDebugEnabled()) {
            logger.debug("Organization: {}", orgObj.toString());
        }

        logger.info("Total amount of all montly: {}", orgObj.getAmountOfToltal());
        String amount = getTotalAmountOfMonth(monthly, orgObj);

        logger.info("Total amount of processing monthly: {}", amount);
        model.addAttribute(DEFAULT_SETTING_AMOUNT, amount);
    } catch (IllegalArgumentException ex) {
        logger.warn(ex.getMessage());
    } catch (ServiceException | TooManyObjectsException ex) {
        logger.error(ex.getMessage(), ex);

        // ???????????
        model.addAttribute(ERROR, true);
        model.addAttribute(ERROR_MESSAGE, getSystemError());
        return getViewName();
    }

    // Check and set editable page
    pageEditable(monthly, businessDay, model);

    logger.info("Koguchi page view rendered!");
    return getViewName();
}

From source file:com.turborep.turbotracker.banking.controller.BankingController.java

@RequestMapping(value = "/printCheck", method = RequestMethod.POST)
//public @ResponseBody Motransaction printChecks(@RequestParam(value = "bankAccounts", required = false) Integer bankAccountsID,
public @ResponseBody String printChecks(
        @RequestParam(value = "bankAccounts", required = false) Integer bankAccountsID,
        @RequestParam(value = "checksDate", required = false) Date checkDate,
        @RequestParam(value = "checkType", required = false) String checkType,
        @RequestParam(value = "checkNumber", required = false) Integer checkNumber,
        @RequestParam(value = "coFiscalPeriodId", required = false) Integer periodid,
        @RequestParam(value = "coFiscalYearId", required = false) Integer yearid, HttpSession aSession,
        HttpServletRequest request, HttpServletResponse theResponse)
        throws IOException, CompanyException, MessagingException {
    Motransaction aMotransaction = new Motransaction();
    PrintCheckBean aPrintBean = new PrintCheckBean();
    String status = "";
    UserBean aUserBean;/*from  ww w .  ja  v  a2 s. com*/
    aUserBean = (UserBean) aSession.getAttribute(SessionConstants.USER);
    System.out.println(bankAccountsID);

    try {

        if (checkType.equalsIgnoreCase("Vendorchecks"))
            aMotransaction.setCheckType((short) 1);
        else
            aMotransaction.setCheckType((short) 2);

        aMotransaction.setMoAccountId(bankAccountsID);

        // Get coAccountID
        Coaccount coaccount = gltransactionService.getcoAccountDetails(aMotransaction);

        // Get CurrentAccount Balance
        Motransaction motrans = bankingAccountsService.getResultingBalance(bankAccountsID);

        aMotransaction.setTransactionDate(checkDate);

        Date myDate = new Date();
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
        String dateAsString_format = simpleDateFormat.format(myDate);

        if (myDate.compareTo(aMotransaction.getTransactionDate()) < 0
                || myDate.compareTo(aMotransaction.getTransactionDate()) == 0) {
            aMotransaction.setBalance(motrans.getResultingbalance());
        } else {
            aMotransaction.setBalance(motrans.getCurrentbalance());
        }

        aMotransaction.setCoAccountId(coaccount.getCoAccountId());
        aMotransaction.setPrinted((byte) 1);
        aMotransaction.setMoTransactionTypeId((short) 2);

        aPrintBean = bankingAccountsService.printCheck(aMotransaction, checkNumber, yearid, periodid,
                aUserBean.getFullName(), aUserBean.getUserId());

        status = aPrintBean.getReference();

    } catch (BankingException e) {
        logger.error(e.getMessage(), e);
        theResponse.sendError(e.getItsErrorStatusCode(), e.getMessage());
        sendTransactionException("<b>MoTransactionID:</b>" + aMotransaction.getMoTransactionId()
                + "<br><b>RxMasterID:</b>" + aMotransaction.getRxMasterId(), "Banking.", e, aSession, request);

    }

    return status;
}

From source file:com.aurel.track.linkType.MsProjectLinkTypeBL.java

/**
 * In case of a changed work item violates one or more pred. dependency: this method returns a map containing violated dependencies id.
 * (This method check if actual (changed) work item new start/end date is valid when actual work item is represented as a succ.)
 * @param startDate/*from   w w  w . j  ava2  s  .  com*/
 * @param endDate
 * @param workItemParam
 * @return
 * @throws ItemLoaderException
 */
public static Set<Integer> checkSuccMoveValidity(Date startDate, Date endDate, Integer workItemID,
        Integer personID, TWorkItemLinkBean actualCreatedLink) {
    Map<Integer, Integer> msProjectIdMap = new HashMap<Integer, Integer>();
    MsProjectLinkType msProjectLinkType = MsProjectLinkType.getInstance();
    List<Integer> msProjectLink = LinkTypeBL.getLinkTypesByPluginClass(msProjectLinkType);
    for (int i = 0; i < msProjectLink.size(); i++) {
        int type = (Integer) msProjectLink.get(i);
        msProjectIdMap.put(type, type);
    }
    Set<Integer> problems = new HashSet<Integer>();
    List<TWorkItemLinkBean> links = workItemLinkDao.loadByWorkItemSucc(workItemID);
    if (actualCreatedLink != null) {
        links.add(actualCreatedLink);
    }

    int[] workItemIds;
    ArrayList<Integer> workItemIdsList = new ArrayList<Integer>();
    for (TWorkItemLinkBean actualLinkBean : links) {
        if (msProjectIdMap.containsKey(actualLinkBean.getLinkType())) {
            workItemIdsList.add(actualLinkBean.getLinkPred());
        }
    }

    workItemIds = new int[workItemIdsList.size()];
    for (int i = 0; i < workItemIdsList.size(); i++) {
        workItemIds[i] = workItemIdsList.get(i);
    }
    List<TWorkItemBean> predList = new ArrayList<TWorkItemBean>();
    predList = LoadItemIDListItems.getWorkItemBeansByWorkItemIDs(workItemIds, personID, false, false, false);
    Map<Integer, TWorkItemBean> predMap = new HashMap<Integer, TWorkItemBean>();
    for (int i = 0; i < predList.size(); i++) {
        predMap.put(predList.get(i).getObjectID(), predList.get(i));
    }
    for (TWorkItemLinkBean actualLinkBean : links) {
        if (msProjectIdMap.containsKey(actualLinkBean.getLinkType())) {
            Integer dependencyType = actualLinkBean.getIntegerValue1();
            int predWorkItemId = actualLinkBean.getLinkPred();
            TWorkItemBean predWorkItemBean = predMap.get(predWorkItemId);
            Date predWorkItemStartDate = getStartDate(predWorkItemBean);
            //in case of milestone work item end date is missing
            Date predWorkItemEndDate = getEndDate(predWorkItemBean);
            if (predWorkItemEndDate != null && predWorkItemStartDate != null) {
                if (predWorkItemBean.isMilestone()) {
                    predWorkItemEndDate = predWorkItemStartDate;
                }
                if (actualLinkBean.getLinkLag() != 0
                        && checkLinkLagAvaibilityForCascade(actualLinkBean.getLinkLagFormat())) {
                    int linkLagInDays = getLinkLagInDays(actualLinkBean, workItemID);
                    if (linkLagInDays > 0) {
                        predWorkItemEndDate = stepForward(predWorkItemEndDate, linkLagInDays, true);
                        predWorkItemStartDate = stepBack(predWorkItemStartDate, linkLagInDays, true);
                    } else if (linkLagInDays < 0) {
                        predWorkItemEndDate = stepBack(predWorkItemEndDate, Math.abs(linkLagInDays), true);
                        predWorkItemStartDate = stepForward(predWorkItemStartDate, Math.abs(linkLagInDays),
                                true);
                    }
                }
                if (dependencyType != null) {
                    switch (dependencyType) {
                    case PREDECESSOR_ELEMENT_TYPE.FS:
                        if (predWorkItemEndDate.compareTo(startDate) >= 0) {
                            if (!problems.contains(actualLinkBean.getObjectID())) {
                                problems.add(actualLinkBean.getObjectID());
                            }
                        }
                        break;
                    case PREDECESSOR_ELEMENT_TYPE.FF:
                        if (predWorkItemEndDate.compareTo(endDate) >= 0) {
                            if (!problems.contains(actualLinkBean.getObjectID())) {
                                problems.add(actualLinkBean.getObjectID());
                            }
                        }
                        break;
                    case PREDECESSOR_ELEMENT_TYPE.SF:
                        if (predWorkItemStartDate.compareTo(endDate) > 0) {
                            if (!problems.contains(actualLinkBean.getObjectID())) {
                                problems.add(actualLinkBean.getObjectID());
                            }
                        }
                        break;
                    case PREDECESSOR_ELEMENT_TYPE.SS:
                        if (predWorkItemStartDate.compareTo(startDate) > 0) {
                            if (!problems.contains(actualLinkBean.getObjectID())) {
                                problems.add(actualLinkBean.getObjectID());
                            }
                        }
                        break;
                    }
                }
            }
        }
    }
    return problems;
}

From source file:net.sourceforge.fenixedu.domain.Teacher.java

public List<Advise> getAdvisesByAdviseTypeAndExecutionYear(AdviseType adviseType, ExecutionYear executionYear) {

    List<Advise> result = new ArrayList<Advise>();
    Date executionYearStartDate = executionYear.getBeginDate();
    Date executionYearEndDate = executionYear.getEndDate();

    for (Advise advise : this.getAdvisesSet()) {
        if ((advise.getAdviseType() == adviseType)) {
            Date adviseStartDate = advise.getStartExecutionPeriod().getBeginDate();
            Date adviseEndDate = advise.getEndExecutionPeriod().getEndDate();

            if (((executionYearStartDate.compareTo(adviseStartDate) < 0)
                    && (executionYearEndDate.compareTo(adviseStartDate) < 0))
                    || ((executionYearStartDate.compareTo(adviseEndDate) > 0)
                            && (executionYearEndDate.compareTo(adviseEndDate) > 0))) {
                continue;
            }/*from  ww w. j a  v  a2  s. c o  m*/
            result.add(advise);
        }
    }

    return result;
}

From source file:org.egov.works.web.actions.contractorBill.AjaxContractorBillAction.java

public String getLastBillDate() {
    List<EgBillregister> billList;
    Date latestBillDt;
    latestBillDateStr = "";
    final WorkOrderEstimate workOrderEstimate = (WorkOrderEstimate) persistenceService
            .find("from WorkOrderEstimate where id=?", workOrderEstimateId);
    if (workOrderEstimate != null) {
        billList = contractorBillService.getListOfNonCancelledBillsforEstimate(workOrderEstimate.getEstimate(),
                new Date());
        if (billList != null && !billList.isEmpty()) {
            latestBillDt = billList.get(0).getBilldate();
            for (final EgBillregister bill : billList)
                if (latestBillDt.compareTo(bill.getBilldate()) < 0)
                    latestBillDt = bill.getBilldate();
            latestBillDateStr = new SimpleDateFormat("dd/MM/yyyy").format(latestBillDt);
        }//from ww  w. j  a  v  a  2 s .  co  m
    }
    return LATEST_APPROVED_BILL_DATE;
}