Example usage for org.apache.commons.lang.time DateFormatUtils format

List of usage examples for org.apache.commons.lang.time DateFormatUtils format

Introduction

In this page you can find the example usage for org.apache.commons.lang.time DateFormatUtils format.

Prototype

public static String format(Date date, String pattern) 

Source Link

Document

Formats a date/time into a specific pattern.

Usage

From source file:gtu._work.ui.SvnLastestCommitInfoUI.java

String getSaveCurrentDataFileName() {
    return String.format("%s_%s_%s_data.cfg", //
            SvnLastestCommitInfoUI.class.getSimpleName(), //
            projectName, //
            DateFormatUtils.format(System.currentTimeMillis(), "yyyyMMdd_HHmmss"));
}

From source file:gtu._work.ui.DirectoryCompareUI.java

/**
 * ?/*  w w  w . j  a va 2 s.  c  o m*/
 */
private void pourOutFilesByOrignPath(boolean isLeftPourOut) {
    try {
        JTableUtil util = JTableUtil.newInstance(dirCompareTable);
        int[] rows = util.getSelectedRows();
        System.out.println(Arrays.toString(rows));
        if (rows == null || rows.length == 0) {
            JCommonUtil._jOptionPane_showMessageDialog_error("?!");
            return;
        }

        File pourDir = new File(leftDirText.getText());
        if (!isLeftPourOut) {
            pourDir = new File(rightDirText.getText());
        }

        if (!pourDir.exists() || !pourDir.isDirectory()) {
            JCommonUtil._jOptionPane_showMessageDialog_error("base? : " + pourDir);
            return;
        }

        File pourBaseDir = new File(FileUtil.DESKTOP_DIR + File.separator + //
                "pourOut_" + DateFormatUtils.format(System.currentTimeMillis(), "yyyyMMddHHmmss") + //
                File.separator + pourDir.getName());
        if (!pourBaseDir.exists()) {
            pourBaseDir.mkdirs();
        }

        String basePath = pourDir.getAbsolutePath().toString();

        List<File> fileList = new ArrayList<File>();
        for (int ii = 0; ii < rows.length; ii++) {
            InfoObj obj = getInfoObj(rows[ii], util);
            File mainFile = obj.mainFile.getFile();
            File compareToFile = obj.compareToFile.getFile();
            System.out.println("mainFile : " + mainFile);
            System.out.println("compareToFile : " + compareToFile);

            File pourFile = mainFile;
            if (!isLeftPourOut) {
                pourFile = compareToFile;
            }

            if (!pourFile.getAbsolutePath().toLowerCase().startsWith(basePath.toLowerCase())) {
                JCommonUtil._jOptionPane_showMessageDialog_error(
                        "?base???  \nbase : " + basePath + "\n target : "
                                + pourFile);
                return;
            }

            String newPath = pourFile.getAbsolutePath().toString().substring(basePath.length());
            System.out.println("newPath - " + newPath);

            File toFile = new File(pourBaseDir, File.separator + newPath);
            if (!toFile.getParentFile().exists()) {
                toFile.getParentFile().mkdirs();
            }
            FileUtil.copyFile(pourFile, toFile);

            fileList.add(toFile);
        }

        StringBuffer sb = new StringBuffer();
        for (File v : fileList) {
            sb.append(v + "\r\n");
        }

        FileUtil.saveToFile(new File(pourBaseDir, "pourFiles.log"), sb.toString(), "UTF8");
        JCommonUtil._jOptionPane_showMessageDialog_info("?!  : " + fileList.size());
    } catch (Exception ex) {
        JCommonUtil.handleException(ex);
    }
}

From source file:com.sisrni.managedbean.ProyectoConsultarMB.java

public void preUpdateProyecto(Integer id) {
    try {// w  w  w .j  a  v a  2s .  c o m
        Proyecto proyectoactual = proyectoService.findById(id);
        if (proyectoactual != null) {
            proyecto = proyectoactual;
            persona = getPersonaProyecto(proyecto.getPersonaProyectoList(), "REFERENTE INTERNO");
            personaAsistente = getPersonaProyecto(proyecto.getPersonaProyectoList(),
                    "ASISTENTE DE COORDINADOR");
            if (personaAsistente == null) {
                asistenteNull = true;
                personaAsistente = new Persona();
                tabAsis = false;
            } else {
                asistenteNull = false;
                tabAsis = true;
            }
            personaExterna = getPersonaProyecto(proyecto.getPersonaProyectoList(), "REFERENTE EXTERNO");
            organismoSelectedRefExt = personaExterna.getIdOrganismo();
            organismoSelectedRefExt = organismoService
                    .findById(personaExterna.getIdOrganismo().getIdOrganismo());
            organismoList.clear();
            organismoList.add(organismoSelectedRefExt);
            if (proyecto.getIdFacultad() == null) {
                facultadSelectedPojoP = proyecto.getIdUnidad() + ",2";
                PojoFacultadesUnidades j = new PojoFacultadesUnidades();
                for (PojoFacultadesUnidades pojo : facultadesUnidadesList) {
                    if (pojo.getValue().equalsIgnoreCase(facultadSelectedPojoP)) {
                        j = pojo;
                    }
                }
                facultadesUnidadesList.clear();
                facultadesUnidadesList.add(j);
            } else {
                facultadSelectedPojoP = proyecto.getIdFacultad().getIdFacultad() + ",1";
                PojoFacultadesUnidades j = new PojoFacultadesUnidades();
                for (PojoFacultadesUnidades pojo : facultadesUnidadesList) {
                    if (pojo.getValue().equalsIgnoreCase(facultadSelectedPojoP)) {
                        j = pojo;
                    }
                }
                facultadesUnidadesList.clear();
                facultadesUnidadesList.add(j);
            }
            searchByDocInterno(persona.getDuiPersona());
            searchByDocAsistente(personaAsistente.getDuiPersona());
            searchByDocReferenteExterno(personaExterna.getPasaporte());
            proyectoSelected = tipoProyectoService.findById(proyecto.getIdTipoProyecto().getIdTipoProyecto());
            tipoproyectolist.clear();
            tipoproyectolist.add(proyectoSelected);
            tipoCambioSelected = tipoCambioService.findById(2);
            tipoCambioList.clear();
            tipoCambioList.add(tipoCambioSelected);
            fechaInicio = DateFormatUtils.format(proyecto.getFechaInicio(), "dd/MM/yyyy");
            fechaFin = DateFormatUtils.format(proyecto.getFechaFin(), "dd/MM/yyyy");
            if (proyecto.getIdPropuestaConvenio() == null) {
                propuestaConvenioList.clear();
            } else {
                propuestaConvenioSelected = propuestaConvenioService
                        .getByID(proyecto.getIdPropuestaConvenio().getIdPropuesta());
                propuestaConvenioList.clear();
                propuestaConvenioList.add(propuestaConvenioSelected);
            }
            paisCooperanteSelected = paisService.findById(proyecto.getIdPaisCooperante().getIdPais());
            paisCooperanteList.clear();
            paisCooperanteList.add(paisCooperanteSelected);
            cargarOrganismos(proyecto.getOrganismoList());
            cargarAreas(proyecto.getAreaConocimientoList());
            cargarFacultadesBeneficiadas(proyecto.getFacultadList());
            actualizar = Boolean.TRUE;
            if (consultar != true) {
                FacesContext.getCurrentInstance().getExternalContext().redirect("registrarProyecto.xhtml");
            } else {
                FacesContext.getCurrentInstance().getExternalContext().redirect("consultarProyecto.xhtml");
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:edu.duke.cabig.c3pr.webservice.converters.JAXBToDomainObjectConverterImpl.java

/**
 * Convert to ts date time./*from  w w w .j  ava 2 s. c o  m*/
 *
 * @param date the date
 * @return the tS date time
 */
protected TSDateTime convertToTsDateTime(Date date) {
    TSDateTime tsDateTime = new TSDateTime();
    if (date != null) {
        tsDateTime.setValue(DateFormatUtils.format(date, TS_DATETIME_PATTERN));
    } else {
        tsDateTime.setNullFlavor(NullFlavor.NI);
    }
    return tsDateTime;
}

From source file:gtu._work.ui.SvnLastestCommitInfoUI.java

void addRow(SvnFile svnFile, DefaultTableModel model) {
    model.addRow(new Object[] { //
            svnFile.fileName, //
            svnFile.author, //
            svnFile.lastestVersion, //
            DateFormatUtils.format(svnFile.file.lastModified(), "yyyy/MM/dd HH:mm:ss"), //
            svnFile.file.length() / 1024 + "k", //
            svnFile //
    });//from   w w w.ja  v a  2 s . c  o m
}

From source file:gtu._work.mvn.MavenRepositoryUI.java

void resetUIStatus() {
    {/*w w  w.ja v a 2  s  .c o  m*/
        DefaultListModel model = new DefaultListModel();
        for (PomFile pom : pomFileList) {
            model.addElement(pom);
        }
        scanList.setModel(model);
    }
    {
        DefaultListModel model = new DefaultListModel();
        for (PomFile pom : pomFileJarList) {
            model.addElement(pom);
        }
        scanList2.setModel(model);
    }
    {
        Object[] header = new Object[] { "pom", "lastModified", "jar", "parent", "modelVersion", " groupId",
                " artifactId", " packaging", " name", " version", " url", " description" };
        DefaultTableModel model = new DefaultTableModel(new Object[][] {}, header) {
            private static final long serialVersionUID = 1L;

            public boolean isCellEditable(int row, int column) {
                return false;
            }
        };
        for (PomFile pom : pomFileList) {
            model.addRow(new Object[] { //
                    pom, //
                    DateFormatUtils.format(pom.xmlFile.lastModified(), "yyyy/MM/dd HH:mm:ss"), //
                    (pom.jarFile == null ? ""
                            : DateFormatUtils.format(pom.jarFile.lastModified(), "yyyy/MM/dd HH:mm:ss") + "("
                                    + (pom.jarFile.length() / 1024) + ")"), //
                    (pom.pom.parent == null ? "" : "Y"), //
                    pom.pom.modelVersion, //
                    pom.pom.groupId, //
                    pom.pom.artifactId, //
                    pom.pom.packaging, //
                    pom.pom.name, //
                    pom.pom.version, //
                    pom.pom.url, //
                    pom.pom.description //
            });
        }
        scanTable.setModel(model);
    }

    scanText.getDocument().addDocumentListener(getDocumentListener(scanList, pomFileList));
    scanText2.getDocument().addDocumentListener(getDocumentListener(scanList2, pomFileJarList));
}

From source file:com.hrbb.loan.pos.biz.backstage.inter.impl.LoanPosCreditApplyBackStageBizImpl.java

/**
     * App??? .// w  w w.j av  a  2s  .  co m
     * 
     * @param loanId
     * @param custId
     * @param paperKind
     * @param paperId
     * @param custName
     * @param beginDate
     * @param endDate
     * @return
     */
    public List<Map<String, Object>> queryCreditApplyDetailByZzApp(String loanId, String custId, String paperKind,
            String paperId, String custName, String beginDate, String endDate) {
        Boolean flag = false;
        Map<String, Object> queryMap = Maps.newHashMap();
        try {
            // ??
            if (!StringUtil.isEmpty(loanId)) {
                queryMap.put("loanId", loanId);
            }
            if (!StringUtil.isEmpty(custId)) {
                queryMap.put("custId", custId);
            }
            if (!StringUtil.isEmpty(paperId)) {
                queryMap.put("paperKind", paperKind);
                queryMap.put("paperId", paperId);
            }
            if (!StringUtil.isEmpty(beginDate)) {
                queryMap.put("beginDate", new Timestamp(DateUtil.getTimeStamp(beginDate)));
            }
            if (!StringUtil.isEmpty(endDate)) {
                queryMap.put("endDate", new Timestamp(DateUtil.getTimeStamp(endDate)));
            }

            // ?
            List<Map<String, Object>> returnList = loanPosCreditApplyService.queryListByZzApp(queryMap);
            if (!returnList.isEmpty()) {
                // ??
                for (Map<String, Object> map : returnList) {
                    // 
                    if (ReviewNoteConstants.APPLYSTATUS_CODE_21.equals(map.get("apprstate"))
                            || ReviewNoteConstants.APPLYSTATUS_CODE_32.equals(map.get("apprstate"))) {
                        TCreditApplyAprvInfo tCreditApplyAprvInfoKey = new TCreditApplyAprvInfo();
                        tCreditApplyAprvInfoKey.setLoanId((String) map.get("loanid"));
                        tCreditApplyAprvInfoKey.setApprResult(ReviewNoteConstants.APPRRESULT_CODE_31);
                        TCreditApplyAprvInfo tCreditApplyAprvInfo = tCreditApplyAprvInfoDao
                                .selectLastOne(tCreditApplyAprvInfoKey);
                        if (tCreditApplyAprvInfo != null) {
                            map.put("additspec", tCreditApplyAprvInfo.getNeedReason());
                            map.put("imgadditdetail", tCreditApplyAprvInfo.getNeedInforCodes());
                        }

                        // 
                        map.put("loancountdown", calculatingTimeDiff((String) map.get("begindate"), "D", 14));

                        // ?
                    } else if (ReviewNoteConstants.APPLYSTATUS_CODE_92.equals(map.get("apprstate"))) {
                        TCreditApplyAprvInfo tCreditApplyAprvInfoKey = new TCreditApplyAprvInfo();
                        tCreditApplyAprvInfoKey.setLoanId((String) map.get("loanid"));
                        tCreditApplyAprvInfoKey.setApprResult(ReviewNoteConstants.APPRRESULT_CODE_20);
                        TCreditApplyAprvInfo tCreditApplyAprvInfo = tCreditApplyAprvInfoDao
                                .selectLastOne(tCreditApplyAprvInfoKey);
                        if (tCreditApplyAprvInfo != null) {
                            //20150728 guoyu ????
                            //map.put("refusereason", tCreditApplyAprvInfo.getApprInfoExt());
                            map.put("refusereason", businessDictionaryService
                                    .getApprInfoExtMsg(tCreditApplyAprvInfo.getApprInfoExt()));
                        }

                        // 
                        map.put("loancountdown", calculatingTimeDiff((String) map.get("begindate"), "M", 3));
                        // 
                    } else if (ReviewNoteConstants.APPLYSTATUS_CODE_90.equals(map.get("apprstate"))) {
                        TApproveResult tApproveResult = tApproveResultDao
                                .selectByLoanId((String) map.get("loanid"));
                        if (tApproveResult != null) {
                            map.put("appmaxcred", tApproveResult.getApproveAmount()); // ?
                            map.put("apptterm", tApproveResult.getApproveTerm()); // ?
                            map.put("interate", tApproveResult.getApproveInterest()); // 
                            map.put("appenddate", tApproveResult.getExpiryDate() == null ? ""
                                    : DateFormatUtils.format(tApproveResult.getExpiryDate(), "yyyyMMdd")); // ?
                        }
                        TContractManagement tContractInfo = tContractInfoDao
                                .selectContractInfoByLoanId((String) map.get("loanid"));
                        if (tContractInfo != null && "05|09".indexOf(tContractInfo.getAgreementStatus()) < 0) {
                            map.put("apprstate", "191"); // 191, 
                            Calendar calNow = Calendar.getInstance();
                            logger.debug(":" + calNow.getTime());
                            Calendar cal = Calendar.getInstance();
                            cal.setTime(tContractInfo.getEndDate());
                            cal.add(Calendar.MONTH, -1);
                            logger.debug("????" + cal.getTime());
                            Calendar calEnd = Calendar.getInstance();
                            logger.debug("???:" + calEnd.getTime());
                            calEnd.setTime(tContractInfo.getEndDate());
                            //????
                            if (tContractInfo.getAgreementStatus() != null
                                    && "06".equals(tContractInfo.getAgreementStatus())) {
                                logger.debug(loanId + "?");
                                if (calNow.compareTo(cal) >= 0 && calNow.compareTo(calEnd) < 0) {
                                    flag = true;
                                }
                            }
                        }

                        // 
                        map.put("loancountdown", calculatingTimeDiff((String) map.get("begindate"), "D", 7));
                    } else if ("10|20|30|31|33|34".indexOf((String) map.get("apprstate")) > -1) {
                        // 
                        map.put("loancountdown", calculatingTimeDiff((String) map.get("begindate"), "D", 2));
                    }
                    if (flag) {
                        map.put("reloanflag", "Y"); // ?
                    } else {
                        map.put("reloanflag", "N"); // ??
                    }
                }
            }
            return returnList;
        } catch (Exception e) {
            logger.error("App??? :[]", e.getMessage());
            return null;
        }
    }

From source file:com.turborep.turbotracker.banking.service.BankingServiceImpl.java

@Override
public List<Motransaction> getTransactionRegisterListForReconcile(int moAccountId, int TransactionType,
        String sortType, String sortBy) throws BankingException {
    Session aSession = null;//from   www .  ja v a2 s.c  o  m

    itsLogger.info("TransactionType::[" + TransactionType + "]");

    List<Motransaction> aQueryList = new ArrayList<Motransaction>();
    String aCustomerQry = null;
    if (sortBy.equals("transDate")) {
        sortBy = "TransactionDate";
    }
    if (sortBy.equals("description")) {
        sortBy = "reference";
    }
    /*if(TransactionType==0){
       aCustomerQry = "select mo.Description,mo.Amount,mo.TransactionDate,mo.Void,mo.CheckType,mo.Reference,mo.TempRec,mo.moTransactionTypeID,"
       + "mo.coAccountID,mo.moAccountID,mo.moTransactionId from moTransaction mo where mo.moAccountID="+moAccountId+" and mo.Void=0 "
       + "and mo.Reconciled=0 and mo.moTransactionTypeID IN ('0','4') ORDER BY "+sortBy+" "+sortType;
    }else{
    aCustomerQry = "select rx.Name,mo.Amount,mo.TransactionDate,mo.Void,mo.CheckType,mo.Reference,mo.TempRec,mo.moTransactionTypeID,mo.coAccountID,"
       + "mo.moAccountID,mo.moTransactionId,rx.rxMasterID from moTransaction mo join rxMaster rx on mo.rxMasterID=rx.rxMasterID "
       + " where mo.moAccountID="+moAccountId+" and mo.Void=0 and mo.Reconciled=0 and mo.moTransactionTypeID IN ('1','2','3') "
       + "ORDER BY "+sortBy+" "+sortType;
    }*/

    if (TransactionType == 0) {
        aCustomerQry = "SELECT moTransactionID,TempRec,moTransactionTypeID,Amount,TransactionDate,Reference,Description,Amount AS TheAmount,coAccountID "
                + "FROM moTransaction WHERE Void = 0 AND Reconciled = 0 and status = 0 AND moAccountID="
                + moAccountId + " AND  NOT (moTransactionTypeID IN (1,2,3)) ORDER BY " + sortBy + " "
                + sortType;
    } else {
        aCustomerQry = "SELECT moTransactionID,TempRec,moTransactionTypeID,Amount,TransactionDate,Reference,  "
                + "(CASE WHEN Description IS NULL THEN rxMaster.Name ELSE Description END)  AS Description, "
                + "-Amount AS TheAmount,coAccountID FROM moTransaction LEFT JOIN rxMaster ON moTransaction.rxMasterID = rxMaster.rxMasterID "
                + "WHERE Void = 0 AND Reconciled = 0 and status=0 AND moAccountID=" + moAccountId
                + " AND  moTransactionTypeID IN (1,2,3) " + "ORDER BY " + sortBy + " " + sortType;
    }

    Motransaction aMotransaction = null;
    try {
        aSession = itsSessionFactory.openSession();
        Query aQuery = aSession.createSQLQuery(aCustomerQry);
        Iterator<?> aIterator = aQuery.list().iterator();
        while (aIterator.hasNext()) {

            aMotransaction = new Motransaction();
            Object[] aObj = (Object[]) aIterator.next();
            if (aObj[4] != null) {
                aMotransaction.setMoTransactionId((Integer) aObj[0]);
                aMotransaction.setTempRec((Byte) aObj[1]);
                aMotransaction.setMoTransactionTypeId((Short) aObj[2]);
                aMotransaction.setAmount((BigDecimal) aObj[3]);
                aMotransaction.setTransDate((String) DateFormatUtils.format((Date) aObj[4], "MM/dd/yyyy"));
                aMotransaction.setReference((String) aObj[5]);
                aMotransaction.setDescription((String) aObj[6]);
                aMotransaction.setTheAmount((BigDecimal) aObj[7]);
                aMotransaction.setCoAccountId((Integer) aObj[8]);
                aMotransaction.setMoAccountId(moAccountId);

                if (aMotransaction.getMoTransactionTypeId() == 0) {
                    aMotransaction.setDescription("Deposit");
                }
                if (aMotransaction.getMoTransactionTypeId() == 4) {
                    aMotransaction.setDescription("Interest");
                    aMotransaction.setAmount(aMotransaction.getAmount());
                }

                /*aMotransaction.setTransactionDate((Date) aObj[2]);
                aMotransaction.setVoid_((Byte) aObj[3]);
                aMotransaction.setCheckType((Short) aObj[4]);
                aMotransaction.setCoAccountId((Integer) aObj[8]);
                              
                if(TransactionType==2){
                   aMotransaction.setRxMasterId((Integer) aObj[11]);
                }*/

                aQueryList.add(aMotransaction);
            }
        }
    } catch (Exception e) {
        itsLogger.error(e.getMessage(), e);
        BankingException aBankingException = new BankingException(e.getMessage(), e);
        throw aBankingException;
    } finally {
        aSession.flush();
        aSession.close();
        aCustomerQry = null;
    }
    return aQueryList;
}

From source file:com.turborep.turbotracker.banking.service.BankingServiceImpl.java

@Override
public List<Motransaction> findbytransactionRegisterList(int theFrom, int theTo, ArrayList<?> theFilterDetails,
        int moaccountid) throws BankingException {
    Session aSession = null;/*ww w . j a va2s. c om*/
    String param1 = null, param2 = null, value = null, param3 = "0";

    if (theFilterDetails != null) {
        for (int i = 0; i < theFilterDetails.size(); i++) {
            if (i == 0) {
                param1 = theFilterDetails.get(i).toString();
            } else if (i == 1) {
                param2 = theFilterDetails.get(i).toString();
            } else if (i == 2) {
                value = theFilterDetails.get(i).toString();
            } else if (i == 3) {
                param3 = theFilterDetails.get(i).toString();
            }
        }
    }
    List<Motransaction> aQueryList = new ArrayList<Motransaction>();
    String aCustomerQry = "SELECT *,CASE WHEN moTransaction.rxMasterID IS NULL THEN description ELSE (SELECT NAME FROM rxMaster WHERE "
            + " rxMasterID=moTransaction.rxMasterID) END 'namedescription' FROM moTransaction WHERE moAccountID ="
            + moaccountid;
    Motransaction aMotransaction = null;

    if (param1 != null && param1.equalsIgnoreCase("Amount")) {
        if (param2 != null && param2.equalsIgnoreCase("Exact"))
            aCustomerQry += " and IF(amount < 0, amount*-1, amount)  =" + value;
        else if (param2 != null && param2.equalsIgnoreCase("Greater"))
            aCustomerQry += " and IF(amount < 0, amount*-1, amount)  >" + value;
        else if (param2 != null && param2.equalsIgnoreCase("Greater or equal"))
            aCustomerQry += " and IF(amount < 0, amount*-1, amount)  >=" + value;
        else if (param2 != null && param2.equalsIgnoreCase("Less"))
            aCustomerQry += " and IF(amount < 0, amount*-1, amount) <" + value;
        else if (param2 != null && param2.equalsIgnoreCase("Less or equal"))
            aCustomerQry += " and IF(amount < 0, amount*-1, amount)  <=" + value;

    } else if (param1 != null && param1.equalsIgnoreCase("Cleared Status")) {
        if (param2 != null && param2.equalsIgnoreCase("Reconcile"))
            aCustomerQry += " and reconciled=1 ";
        else if (param2 != null && param2.equalsIgnoreCase("Unreconciled"))
            aCustomerQry += " and reconciled=0 and status=0";

        /*if (param3.equals("0"))
           aCustomerQry += " limit " + theFrom + " ," + theTo;
        if (param3.equals("1"))
           aCustomerQry += " limit " + theFrom + " ," + theTo;*/

        System.out.println("==============================================>" + aCustomerQry);

    } else if (param1 != null && param1.equalsIgnoreCase("Date")) {
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
        SimpleDateFormat parseDateFormat = new SimpleDateFormat("MM/dd/yyyy");
        Date fromDate = null, toDate = null;
        try {
            if (param2 != null)
                fromDate = parseDateFormat.parse(param2);

        } catch (ParseException e) {
            e.printStackTrace();
        }
        if (param2 != null && value.equals("0"))
            aCustomerQry += " and transactionDate >='" + simpleDateFormat.format(fromDate) + "'";
        else if (param2 == null && value != null)
            aCustomerQry += " and transactionDate <='" + simpleDateFormat.format(toDate) + "'";
        else if (param2 != null && value != null && !value.equals("0")) {
            if (value != null && !value.equals("0"))
                try {
                    toDate = parseDateFormat.parse(value);
                } catch (ParseException e) {
                    e.printStackTrace();
                }
            aCustomerQry += " and transactionDate between '" + simpleDateFormat.format(fromDate) + "' and '"
                    + simpleDateFormat.format(toDate) + "'";
        }
    } else if (param1 != null && param1.equalsIgnoreCase("Reference")) {
        if (param2 != null && param2.equalsIgnoreCase("Contains"))
            aCustomerQry += " and reference like '%" + value + "%'";
        else if (param2 != null && param2.equalsIgnoreCase("Exact"))
            aCustomerQry += " and reference ='" + value + "'";
    } else if (param1 != null && param1.equalsIgnoreCase("G/L Account #")) {
        aCustomerQry += " and coAccountID =" + param2 + "";
    } else if (param1 != null && param1.equalsIgnoreCase("Type")) {
        if (param2 != null && param2.equalsIgnoreCase("Deposit"))
            aCustomerQry += " and amount > 0 ";
        else
            aCustomerQry += " and amount < 0 ";
    }

    //aCustomerQry +=" ORDER BY moTransactionID DESC";
    String sort = (String) theFilterDetails.get(theFilterDetails.size() - 1);

    String descriptionFilter = "";

    if (param1 != null && param1.equalsIgnoreCase("Description")) {

        if (sort.equals("0"))
            aCustomerQry += " ORDER BY transactionDate ASC";
        else
            aCustomerQry += " ORDER BY transactionDate DESC";

        if (param2 != null && param2.equalsIgnoreCase("Contains"))
            descriptionFilter += "  description like '%" + value + "%' or namedescription like '%" + value
                    + "%'";
        else if (param2 != null && param2.equalsIgnoreCase("Ends with"))
            descriptionFilter += "  description like '%" + value + "' or namedescription like '%" + value + "'";
        else if (param2 != null && param2.equalsIgnoreCase("Exact"))
            descriptionFilter += "  description ='" + value + "' or namedescription = '" + value + "'";
        else if (param2 != null && param2.equalsIgnoreCase("Starts with"))
            descriptionFilter += "  description like '" + value + "%' or namedescription like '" + value + "%'";

        aCustomerQry = "Select * from (" + aCustomerQry + ")as subquery where " + descriptionFilter;

        if (sort.equals("0"))
            aCustomerQry += " limit " + theFrom + " ," + theTo;
        else
            aCustomerQry += " limit " + theFrom + " ," + theTo;

    } else {
        if (sort.equals("0"))
            aCustomerQry += " ORDER BY transactionDate ASC limit " + theFrom + " ," + theTo;
        else
            aCustomerQry += " ORDER BY transactionDate DESC limit " + theFrom + " ," + theTo;

    }

    System.out.println("aCustomerQry===" + aCustomerQry);

    try {
        aSession = itsSessionFactory.openSession();
        Query aQuery = aSession.createSQLQuery(aCustomerQry);
        Iterator<?> aIterator = aQuery.list().iterator();
        while (aIterator.hasNext()) {
            aMotransaction = new Motransaction();
            Object[] aObj = (Object[]) aIterator.next();
            aMotransaction.setMoTransactionId((Integer) aObj[0]);
            aMotransaction.setRxMasterId((Integer) aObj[1]);
            aMotransaction.setRxAddressId((Integer) aObj[2]);
            aMotransaction.setCoAccountId((Integer) aObj[3]);
            aMotransaction.setMoAccountId((Integer) aObj[4]);
            if (aObj[5] != null && aObj[5] != "")
                aMotransaction.setTransDate((String) DateFormatUtils.format((Date) aObj[5], "MM/dd/yyyy"));
            aMotransaction.setMoTransactionTypeId((Short) aObj[6]);
            aMotransaction.setMoTypeId((Short) aObj[6]);
            aMotransaction.setCheckType((Short) aObj[7]);
            aMotransaction.setReference((String) aObj[8]);
            aMotransaction.setDescription((String) aObj[9]);
            aMotransaction.setVoid_((Byte) aObj[10]);
            aMotransaction.setReconciled((Byte) aObj[11]);
            aMotransaction.setTempRec((Byte) aObj[12]);
            aMotransaction.setPrinted((Byte) aObj[13]);
            aMotransaction.setAmount((BigDecimal) aObj[14]);
            aMotransaction.setWithDrawel((BigDecimal) aObj[14]);
            aMotransaction.setDirectDeposit((Byte) aObj[15]);

            aMotransaction.setBalance((BigDecimal) aObj[16]);
            aMotransaction.setStatus((Boolean) aObj[17]);
            aMotransaction.setMemo((String) aObj[18]);
            aMotransaction.setDisplaydiscription((String) aObj[21]);

            Date myDate = new Date();
            String futureornot = "Current Transaction";
            if ((Date) aObj[5] != null) {
                if (myDate.compareTo((Date) aObj[5]) < 0 || myDate.compareTo((Date) aObj[5]) == 0) {
                    futureornot = "Future Transaction";
                } else {
                    futureornot = "Current Transaction";
                }
            }
            aMotransaction.setFutureorcurrent(futureornot);
            aQueryList.add(aMotransaction);
        }
    } catch (Exception e) {
        itsLogger.error(e.getMessage(), e);
        BankingException aBankingException = new BankingException(e.getMessage(), e);
        throw aBankingException;
    } finally {
        aSession.flush();
        aSession.close();
        aCustomerQry = null;
    }
    return aQueryList;
}

From source file:nu.mine.kino.entity.OutputScheduleBean.java

public String getScheduledEndDateStr() {
    return getScheduledEndDate() != null ? DateFormatUtils.format(getScheduledEndDate(), "yyyy/MM/dd") : null;
}