Example usage for java.sql Date getTime

List of usage examples for java.sql Date getTime

Introduction

In this page you can find the example usage for java.sql Date getTime.

Prototype

public long getTime() 

Source Link

Document

Returns the number of milliseconds since January 1, 1970, 00:00:00 GMT represented by this Date object.

Usage

From source file:edu.harvard.i2b2.ontology.dao.GetCodeInfoDao.java

public List findCodeInfo(final VocabRequestType vocabType, final List categories, ProjectType projectInfo)
        throws DataAccessException, I2B2Exception {
    DataSource ds = null;//w w  w.ja  v  a 2s.  com
    try {
        ds = OntologyUtil.getInstance().getDataSource("java:OntologyLocalDS");
    } catch (I2B2Exception e2) {
        log.error(e2.getMessage());
        throw e2;
    }

    SimpleJdbcTemplate jt = new SimpleJdbcTemplate(ds);

    // find return parameters
    String parameters = DEFAULT;
    if (vocabType.getType().equals("core")) {
        parameters = CORE;
    } else if (vocabType.getType().equals("all")) {
        parameters = ALL;
    }
    if (vocabType.isBlob() == true)
        parameters = parameters + BLOB;

    //extract table code
    String tableCd = vocabType.getCategory();
    //      log.info(tableCd);

    // table code to table name conversion
    // Get metadata schema name from properties file.
    String metadataSchema = "";
    try {
        metadataSchema = OntologyUtil.getInstance().getMetaDataSchemaName();
    } catch (I2B2Exception e1) {
        log.error(e1.getMessage());
        throw e1;
    }

    List tableNames = null;
    if (tableCd != null) {
        // table code to table name conversion
        String tableSql = "select distinct(c_table_name) from " + metadataSchema
                + "table_access where c_table_cd = ? ";
        ParameterizedRowMapper<String> map = new ParameterizedRowMapper<String>() {
            public String mapRow(ResultSet rs, int rowNum) throws SQLException {
                String name = (rs.getString("c_table_name"));
                return name;
            }
        };
        tableNames = jt.query(tableSql, map, tableCd);
    } else { // tableCd is null, so query all tables user has access to
        String whereClause = "where ";
        Iterator it = categories.iterator();
        while (it.hasNext()) {
            ConceptType entry = null;
            if (whereClause.equals("where ")) {
                entry = (ConceptType) it.next();
                whereClause = whereClause + " c_table_cd = '" + StringUtil.getTableCd(entry.getKey()) + "' ";
            } else {
                entry = (ConceptType) it.next();
                whereClause = whereClause + " or " + " c_table_cd = '" + StringUtil.getTableCd(entry.getKey())
                        + "' ";
            }
        }
        String tableSql = "select distinct(c_table_name) from " + metadataSchema + "table_access "
                + whereClause;

        ParameterizedRowMapper<String> map = new ParameterizedRowMapper<String>() {
            public String mapRow(ResultSet rs, int rowNum) throws SQLException {
                String name = (rs.getString("c_table_name"));
                return name;
            }
        };

        try {
            tableNames = jt.query(tableSql, map);
        } catch (DataAccessException e) {
            log.error(e.getMessage());
            throw e;
        }
    }

    String hidden = "";
    if (vocabType.isHiddens() == false)
        hidden = " and c_visualattributes not like '_H%'";

    String synonym = "";
    if (vocabType.isSynonyms() == false)
        synonym = " and c_synonym_cd = 'N'";

    String codeInfoSql = null;
    if (tableNames != null) {
        Iterator it = tableNames.iterator();
        String table = (String) it.next();
        String tableCdSql = ", (select distinct(c_table_cd) from " + metadataSchema
                + "TABLE_ACCESS where c_table_name = '" + table + "') as tableCd";
        String basecode = " '" + vocabType.getMatchStr().getValue() + "' ";
        codeInfoSql = "select " + parameters + tableCdSql + " from " + metadataSchema + table
                + " where upper(c_basecode) =  " + basecode.toUpperCase() + hidden + synonym;
        ;
        while (it.hasNext()) {
            table = (String) it.next();
            tableCdSql = ", (select distinct(c_table_cd) from " + metadataSchema
                    + "TABLE_ACCESS where c_table_name = '" + table + "') as tableCd";
            codeInfoSql = codeInfoSql + " union select " + parameters + tableCdSql + " from " + metadataSchema
                    + table + " where upper(c_basecode) =  " + basecode.toUpperCase() + hidden + synonym;
        }
        codeInfoSql = codeInfoSql + " order by c_name ";
    } else
        return null;

    log.debug(codeInfoSql);
    final boolean obfuscatedUserFlag = Roles.getInstance().isRoleOfuscated(projectInfo);

    ParameterizedRowMapper<ExpandedConceptType> mapper = new ParameterizedRowMapper<ExpandedConceptType>() {
        public ExpandedConceptType mapRow(ResultSet rs, int rowNum) throws SQLException {
            ExpandedConceptType entry = new ExpandedConceptType();
            //TODO fix this for all/+blob

            entry.setName(rs.getString("c_name"));
            entry.setTableCd(rs.getString("tablecd"));
            if (vocabType.getType().equals("core")) {
                entry.setKey(rs.getString("c_fullname"));
                entry.setBasecode(rs.getString("c_basecode"));
                entry.setLevel(rs.getInt("c_hlevel"));
                entry.setSynonymCd(rs.getString("c_synonym_cd"));
                entry.setVisualattributes(rs.getString("c_visualattributes"));
                Integer totalNum = rs.getInt("c_totalnum");
                if (obfuscatedUserFlag == false) {
                    entry.setTotalnum(totalNum);
                }
                entry.setFacttablecolumn(rs.getString("c_facttablecolumn"));
                entry.setTablename(rs.getString("c_tablename"));
                entry.setColumnname(rs.getString("c_columnname"));
                entry.setColumndatatype(rs.getString("c_columndatatype"));
                entry.setOperator(rs.getString("c_operator"));
                entry.setDimcode(rs.getString("c_dimcode"));
                entry.setTooltip(rs.getString("c_tooltip"));

            }

            if ((vocabType.getType().equals("all"))) {
                DTOFactory factory = new DTOFactory();
                // make sure date isnt null before converting to XMLGregorianCalendar
                Date date = rs.getDate("update_date");
                if (date == null)
                    entry.setUpdateDate(null);
                else
                    entry.setUpdateDate(factory.getXMLGregorianCalendar(date.getTime()));

                date = rs.getDate("download_date");
                if (date == null)
                    entry.setDownloadDate(null);
                else
                    entry.setDownloadDate(factory.getXMLGregorianCalendar(date.getTime()));

                date = rs.getDate("import_date");
                if (date == null)
                    entry.setImportDate(null);
                else
                    entry.setImportDate(factory.getXMLGregorianCalendar(date.getTime()));

                entry.setSourcesystemCd(rs.getString("sourcesystem_cd"));
                entry.setValuetypeCd(rs.getString("valuetype_cd"));
            }

            return entry;
        }
    };

    List queryResult = null;
    try {
        if (tableNames != null)
            queryResult = jt.query(codeInfoSql, mapper);
    } catch (DataAccessException e) {
        log.error(e.getMessage());
        throw e;
    }
    log.debug("result size = " + queryResult.size());

    if (queryResult != null) {
        if (parameters != DEFAULT) {
            //             fix the key so it equals "\\tableCd\fullname"
            //  in all cases but default
            Iterator it = queryResult.iterator();
            while (it.hasNext()) {
                ExpandedConceptType entry = (ExpandedConceptType) it.next();
                entry.setKey("\\\\" + entry.getTableCd() + entry.getKey());
            }
        }

        // Cant gather clobs when you perform unions....
        //  So you have to loop through all the results and gather clobs         
        if (vocabType.isBlob() == true) {
            Iterator itr = queryResult.iterator();
            while (itr.hasNext()) {
                ConceptType child = (ConceptType) itr.next();
                Iterator it = tableNames.iterator();
                while (it.hasNext()) {
                    String clobSql = "select c_metadataxml, c_comment from " + metadataSchema
                            + (String) it.next() + " where c_name = ? and " + synonym;
                    ParameterizedRowMapper<ConceptType> map = new ParameterizedRowMapper<ConceptType>() {
                        public ConceptType mapRow(ResultSet rs, int rowNum) throws SQLException {
                            ConceptType concept = new ConceptType();
                            try {
                                if (rs.getClob("c_metadataxml") == null) {
                                    concept.setMetadataxml(null);
                                } else {
                                    String c_xml = JDBCUtil.getClobString(rs.getClob("c_metadataxml"));
                                    if ((c_xml != null) && (c_xml.trim().length() > 0)
                                            && (!c_xml.equals("(null)"))) {
                                        SAXBuilder parser = new SAXBuilder();
                                        java.io.StringReader xmlStringReader = new java.io.StringReader(c_xml);
                                        Element rootElement = null;
                                        try {
                                            org.jdom.Document metadataDoc = parser.build(xmlStringReader);
                                            org.jdom.output.DOMOutputter out = new DOMOutputter();
                                            Document doc = out.output(metadataDoc);
                                            rootElement = doc.getDocumentElement();
                                        } catch (JDOMException e) {
                                            log.error(e.getMessage());
                                            concept.setMetadataxml(null);
                                        }
                                        if (rootElement != null) {
                                            XmlValueType xml = new XmlValueType();
                                            xml.getAny().add(rootElement);
                                            concept.setMetadataxml(xml);
                                        }
                                    } else {
                                        concept.setMetadataxml(null);
                                    }
                                }
                            } catch (IOException e) {
                                log.error(e.getMessage());
                                concept.setMetadataxml(null);
                            }
                            try {
                                if (rs.getClob("c_comment") == null) {
                                    concept.setComment(null);
                                } else {
                                    concept.setComment(JDBCUtil.getClobString(rs.getClob("c_comment")));
                                }

                            } catch (IOException e) {
                                log.error(e.getMessage());
                                concept.setComment(null);
                            }
                            return concept;
                        }

                    };
                    List clobResult = null;
                    try {
                        clobResult = jt.query(clobSql, map, child.getName(), child.getTooltip());
                    } catch (DataAccessException e) {
                        log.error(e.getMessage());
                        throw e;
                    }
                    if (clobResult != null) {
                        if ((((ConceptType) (clobResult.get(0))).getMetadataxml() != null)
                                || (((ConceptType) (clobResult.get(0))).getComment() != null)) {

                            child.setMetadataxml(((ConceptType) (clobResult.get(0))).getMetadataxml());
                            child.setComment(((ConceptType) (clobResult.get(0))).getComment());
                            break;
                        }
                    } else {
                        child.setMetadataxml(null);
                        child.setComment(null);
                    }
                }
            }
        }
    }
    return queryResult;

}

From source file:org.mifos.accounts.productdefinition.struts.actionforms.SavingsPrdActionForm.java

private void validateEndDateAgainstCurrentDate(ActionErrors errors, Date startDate, java.util.Date oldEndDate,
        Date endDate) {/*from   ww w . j  a  v  a 2  s . c om*/
    if ((oldEndDate == null && endDate != null)
            || (oldEndDate != null && endDate != null && DateUtils.getDateWithoutTimeStamp(oldEndDate.getTime())
                    .compareTo(DateUtils.getDateWithoutTimeStamp(endDate.getTime())) != 0)) {
        if (DateUtils.getDateWithoutTimeStamp(endDate.getTime())
                .compareTo(DateUtils.getCurrentDateWithoutTimeStamp()) < 0
                || DateUtils.getDateWithoutTimeStamp(startDate.getTime())
                        .compareTo(DateUtils.getDateWithoutTimeStamp(endDate.getTime())) >= 0) {
            addError(errors, "endDate", ProductDefinitionConstants.INVALIDENDDATE);
        }
    }

}

From source file:org.kuali.kfs.pdp.service.impl.PendingTransactionServiceImpl.java

/**
 * Populates and stores a new GLPE for each account detail in the payment group.
 *
 * @param paymentGroup payment group to generate entries for
 * @param achFdocTypeCode doc type for ach disbursements
 * @param checkFdocTypeCod doc type for check disbursements
 * @param reversal boolean indicating if this is a reversal
 */// ww  w  . j  av  a  2  s . c  o  m
protected void populatePaymentGeneralLedgerPendingEntry(PaymentGroup paymentGroup, String achFdocTypeCode,
        String checkFdocTypeCod, boolean reversal) {
    List<PaymentAccountDetail> accountListings = new ArrayList<PaymentAccountDetail>();
    for (PaymentDetail paymentDetail : paymentGroup.getPaymentDetails()) {
        accountListings.addAll(paymentDetail.getAccountDetail());
    }

    GeneralLedgerPendingEntrySequenceHelper sequenceHelper = new GeneralLedgerPendingEntrySequenceHelper();
    for (PaymentAccountDetail paymentAccountDetail : accountListings) {
        GlPendingTransaction glPendingTransaction = new GlPendingTransaction();
        glPendingTransaction.setSequenceNbr(new KualiInteger(sequenceHelper.getSequenceCounter()));

        if (StringUtils.isNotBlank(paymentAccountDetail.getPaymentDetail().getFinancialSystemOriginCode())
                && StringUtils
                        .isNotBlank(paymentAccountDetail.getPaymentDetail().getFinancialDocumentTypeCode())) {
            glPendingTransaction
                    .setFdocRefTypCd(paymentAccountDetail.getPaymentDetail().getFinancialDocumentTypeCode());
            glPendingTransaction
                    .setFsRefOriginCd(paymentAccountDetail.getPaymentDetail().getFinancialSystemOriginCode());
        } else {
            glPendingTransaction.setFdocRefTypCd(PdpConstants.PDP_FDOC_TYPE_CODE);
            glPendingTransaction.setFsRefOriginCd(PdpConstants.PDP_FDOC_ORIGIN_CODE);
        }

        glPendingTransaction.setFinancialBalanceTypeCode(KFSConstants.BALANCE_TYPE_ACTUAL);

        Date transactionTimestamp = new Date(dateTimeService.getCurrentDate().getTime());
        glPendingTransaction.setTransactionDt(transactionTimestamp);
        AccountingPeriod fiscalPeriod = accountingPeriodService
                .getByDate(new java.sql.Date(transactionTimestamp.getTime()));
        glPendingTransaction.setUniversityFiscalYear(fiscalPeriod.getUniversityFiscalYear());
        glPendingTransaction.setUnivFiscalPrdCd(fiscalPeriod.getUniversityFiscalPeriodCode());

        glPendingTransaction.setAccountNumber(paymentAccountDetail.getAccountNbr());
        glPendingTransaction.setSubAccountNumber(paymentAccountDetail.getSubAccountNbr());
        glPendingTransaction.setChartOfAccountsCode(paymentAccountDetail.getFinChartCode());

        if (paymentGroup.getDisbursementType().getCode().equals(PdpConstants.DisbursementTypeCodes.ACH)) {
            glPendingTransaction.setFinancialDocumentTypeCode(achFdocTypeCode);
        } else if (paymentGroup.getDisbursementType().getCode()
                .equals(PdpConstants.DisbursementTypeCodes.CHECK)) {
            glPendingTransaction.setFinancialDocumentTypeCode(checkFdocTypeCod);
        }

        glPendingTransaction.setFsOriginCd(PdpConstants.PDP_FDOC_ORIGIN_CODE);
        glPendingTransaction.setFdocNbr(paymentGroup.getDisbursementNbr().toString());

        Boolean relieveLiabilities = paymentGroup.getBatch().getCustomerProfile().getRelieveLiabilities();
        if ((relieveLiabilities != null) && (relieveLiabilities.booleanValue())
                && paymentAccountDetail.getPaymentDetail().getFinancialDocumentTypeCode() != null) {
            OffsetDefinition offsetDefinition = SpringContext.getBean(OffsetDefinitionService.class)
                    .getByPrimaryId(glPendingTransaction.getUniversityFiscalYear(),
                            glPendingTransaction.getChartOfAccountsCode(),
                            paymentAccountDetail.getPaymentDetail().getFinancialDocumentTypeCode(),
                            glPendingTransaction.getFinancialBalanceTypeCode());
            glPendingTransaction
                    .setFinancialObjectCode(offsetDefinition != null ? offsetDefinition.getFinancialObjectCode()
                            : paymentAccountDetail.getFinObjectCode());
            glPendingTransaction.setFinancialSubObjectCode(KFSConstants.getDashFinancialSubObjectCode());
        } else {
            glPendingTransaction.setFinancialObjectCode(paymentAccountDetail.getFinObjectCode());
            glPendingTransaction.setFinancialSubObjectCode(paymentAccountDetail.getFinSubObjectCode());
        }

        glPendingTransaction.setProjectCd(paymentAccountDetail.getProjectCode());
        glPendingTransaction.setDebitCrdtCd(
                pdpUtilService.isDebit(paymentAccountDetail, reversal) ? KFSConstants.GL_DEBIT_CODE
                        : KFSConstants.GL_CREDIT_CODE);
        glPendingTransaction.setAmount(paymentAccountDetail.getAccountNetAmount().abs());

        //Changes for Research Participant Upload
        String trnDesc = StringUtils.EMPTY;
        CustomerProfile customerProfile = paymentGroup.getBatch().getCustomerProfile();

        if (researchParticipantPaymentValidationService.isResearchParticipantPayment(customerProfile)) {
            BusinessObjectEntry businessObjectEntry = dataDictionaryService.getDataDictionary()
                    .getBusinessObjectEntry(PaymentDetail.class.getName());
            AttributeDefinition attributeDefinition = businessObjectEntry
                    .getAttributeDefinition("paymentGroup.payeeName");
            AttributeSecurity originalPayeeNameAttributeSecurity = attributeDefinition.getAttributeSecurity();
            //This is a temporary work around for an issue introduced with KFSCNTRB-705.
            if (ObjectUtils.isNotNull(originalPayeeNameAttributeSecurity)) {
                String maskLiteral = ((MaskFormatterLiteral) originalPayeeNameAttributeSecurity
                        .getMaskFormatter()).getLiteral();
                trnDesc = maskLiteral;
            }
        } else {
            String payeeName = paymentGroup.getPayeeName();
            if (StringUtils.isNotBlank(payeeName)) {
                trnDesc = payeeName.length() > 40 ? payeeName.substring(0, 40)
                        : StringUtils.rightPad(payeeName, 40);
            }

            if (reversal) {
                String poNbr = paymentAccountDetail.getPaymentDetail().getPurchaseOrderNbr();
                if (StringUtils.isNotBlank(poNbr)) {
                    trnDesc += " "
                            + (poNbr.length() > 9 ? poNbr.substring(0, 9) : StringUtils.rightPad(poNbr, 9));
                }

                String invoiceNbr = paymentAccountDetail.getPaymentDetail().getInvoiceNbr();
                if (StringUtils.isNotBlank(invoiceNbr)) {
                    trnDesc += " " + (invoiceNbr.length() > 14 ? invoiceNbr.substring(0, 14)
                            : StringUtils.rightPad(invoiceNbr, 14));
                }

                if (trnDesc.length() > 40) {
                    trnDesc = trnDesc.substring(0, 40);
                }
            }
        }
        glPendingTransaction.setDescription(trnDesc);

        glPendingTransaction.setOrgDocNbr(paymentAccountDetail.getPaymentDetail().getOrganizationDocNbr());
        glPendingTransaction.setOrgReferenceId(paymentAccountDetail.getOrgReferenceId());
        glPendingTransaction.setFdocRefNbr(paymentAccountDetail.getPaymentDetail().getCustPaymentDocNbr());

        // update the offset account if necessary
        SpringContext.getBean(FlexibleOffsetAccountService.class).updateOffset(glPendingTransaction);

        this.businessObjectService.save(glPendingTransaction);

        sequenceHelper.increment();

        if (bankService.isBankSpecificationEnabled()) {
            this.populateBankOffsetEntry(paymentGroup, glPendingTransaction, sequenceHelper);
        }
    }
}

From source file:org.collectionspace.chain.csp.webui.nuispec.DataGenerator.java

/**
 * create teh date format needed//from w  ww .j  av  a2s .  c  o  m
 * @param dateStr
 * @return
 */
private long dateToLong(String dateStr) {
    java.util.Date d;
    try {
        d = DATE_FORMAT.parse(dateStr);
    } catch (ParseException e) {
        d = new java.util.Date();
    }
    return d.getTime();
}

From source file:org.kuali.kfs.module.tem.document.service.impl.TravelPaymentsHelperServiceImpl.java

/**
 *
 * @see org.kuali.kfs.module.tem.document.service.TravelPaymentsHelperService#buildGenericPaymentDetail(org.kuali.rice.krad.bo.DocumentHeader, java.sql.Date, org.kuali.kfs.module.tem.businessobject.TravelPayment, org.kuali.rice.kim.api.identity.Person, java.lang.String)
 *//* w w  w  .j  a va 2  s.  c  om*/
@Override
public PaymentDetail buildGenericPaymentDetail(DocumentHeader documentHeader, Date processDate,
        TravelPayment travelPayment, Person initiator, String achCheckDocumentType) {
    PaymentDetail pd = new PaymentDetail();
    if (StringUtils.isNotEmpty(documentHeader.getOrganizationDocumentNumber())) {
        pd.setOrganizationDocNbr(documentHeader.getOrganizationDocumentNumber());
    }
    pd.setCustPaymentDocNbr(documentHeader.getDocumentNumber());
    pd.setInvoiceDate(new java.sql.Date(processDate.getTime()));
    pd.setOrigInvoiceAmount(travelPayment.getCheckTotalAmount());
    pd.setInvTotDiscountAmount(KualiDecimal.ZERO);
    pd.setInvTotOtherCreditAmount(KualiDecimal.ZERO);
    pd.setInvTotOtherDebitAmount(KualiDecimal.ZERO);
    pd.setInvTotShipAmount(KualiDecimal.ZERO);
    pd.setNetPaymentAmount(travelPayment.getCheckTotalAmount());
    pd.setPrimaryCancelledPayment(Boolean.FALSE);
    pd.setFinancialDocumentTypeCode(achCheckDocumentType);
    pd.setFinancialSystemOriginCode(KFSConstants.ORIGIN_CODE_KUALI);

    int line = 0;
    PaymentNoteText pnt = new PaymentNoteText();
    pnt.setCustomerNoteLineNbr(new KualiInteger(line++));
    pnt.setCustomerNoteText("Info: " + initiator.getPrincipalName() + " " + initiator.getPhoneNumber());
    pd.addNote(pnt);

    if (StringUtils.isNotEmpty(travelPayment.getSpecialHandlingPersonName())) {
        pnt = new PaymentNoteText();
        pnt.setCustomerNoteLineNbr(new KualiInteger(line++));
        pnt.setCustomerNoteText("Send Check To: " + travelPayment.getSpecialHandlingPersonName());
        if (LOG.isDebugEnabled()) {
            LOG.debug("Creating special handling person name note: " + pnt.getCustomerNoteText());
        }
        pd.addNote(pnt);
    }
    if (StringUtils.isNotEmpty(travelPayment.getSpecialHandlingLine1Addr())) {
        pnt = new PaymentNoteText();
        pnt.setCustomerNoteLineNbr(new KualiInteger(line++));
        pnt.setCustomerNoteText(travelPayment.getSpecialHandlingLine1Addr());
        if (LOG.isDebugEnabled()) {
            LOG.debug("Creating special handling address 1 note: " + pnt.getCustomerNoteText());
        }
        pd.addNote(pnt);
    }
    if (StringUtils.isNotEmpty(travelPayment.getSpecialHandlingLine2Addr())) {
        pnt = new PaymentNoteText();
        pnt.setCustomerNoteLineNbr(new KualiInteger(line++));
        pnt.setCustomerNoteText(travelPayment.getSpecialHandlingLine2Addr());
        if (LOG.isDebugEnabled()) {
            LOG.debug("Creating special handling address 2 note: " + pnt.getCustomerNoteText());
        }
        pd.addNote(pnt);
    }
    if (StringUtils.isNotEmpty(travelPayment.getSpecialHandlingCityName())) {
        pnt = new PaymentNoteText();
        pnt.setCustomerNoteLineNbr(new KualiInteger(line++));
        pnt.setCustomerNoteText(
                travelPayment.getSpecialHandlingCityName() + ", " + travelPayment.getSpecialHandlingStateCode()
                        + " " + travelPayment.getSpecialHandlingZipCode());
        if (LOG.isDebugEnabled()) {
            LOG.debug("Creating special handling city note: " + pnt.getCustomerNoteText());
        }
        pd.addNote(pnt);
    }
    if (travelPayment.isAttachmentCode()) {
        pnt = new PaymentNoteText();
        pnt.setCustomerNoteLineNbr(new KualiInteger(line++));
        pnt.setCustomerNoteText("Attachment Included");
        if (LOG.isDebugEnabled()) {
            LOG.debug("create attachment note: " + pnt.getCustomerNoteText());
        }
        pd.addNote(pnt);
    }

    final String text = travelPayment.getCheckStubText();
    if (!StringUtils.isBlank(text)) {
        pnt = getPaymentSourceHelperService().buildNoteForCheckStubText(text, line);
        if (LOG.isDebugEnabled()) {
            LOG.debug("Creating check stub text note: " + pnt.getCustomerNoteText());
        }
        pd.addNote(pnt);
    }
    return pd;
}

From source file:com.job.portal.utils.AbstractDAO.java

public int insert(String query, Object[] values) throws SQLException {
    int id = -1;//from  w w  w  .  j  a  v  a  2 s . co m
    Object o = null;
    String type = null;
    Date d = null;
    java.util.Date utilDate = null;
    if (con.isClosed()) {
        con = new DbConnection().getConnection();
    }
    ps = con.prepareStatement(query, Statement.RETURN_GENERATED_KEYS);
    for (int i = 0; i < values.length; i++) {
        o = values[i];
        type = o.getClass().toString();
        if (type.contains("String")) {
            ps.setString(i + 1, (String) o);
        } else if (type.contains("Integer")) {
            ps.setInt(i + 1, (Integer) o);
        } else if (type.contains("Long")) {
            ps.setLong(i + 1, (Long) o);
        } else if (type.contains("Date")) {
            utilDate = (java.util.Date) o;
            ps.setDate(i + 1, new Date(utilDate.getTime()));
        }
    }
    id = ps.executeUpdate();
    closeConnections();
    return id;
}

From source file:com.qtplaf.library.util.Calendar.java

/**
 * Constructor assigning a <code>Date</code>.
 *
 * @param date The <code>Date</code>.
 *///from  w ww .  j a  v a2 s.  c  om
public Calendar(java.sql.Date date) {
    setTimeInMillis(date.getTime());
}

From source file:org.kuali.coeus.common.budget.impl.summary.BudgetSummaryServiceImpl.java

protected int getYear(Date date) {
    Calendar c1 = Calendar.getInstance();
    c1.setTime(new java.util.Date(date.getTime()));
    return c1.get(Calendar.YEAR);

}

From source file:nl.ordina.bag.etl.dao.postgres.BAGMutatiesDAOImpl.java

@Override
public long insertMutatiesFile(final java.util.Date dateFrom, final java.util.Date dateTo, final byte[] content)
        throws DAOException {
    try {/*from w ww. j av a  2 s.  c om*/
        return jdbcTemplate.query(new PreparedStatementCreator() {
            @Override
            public PreparedStatement createPreparedStatement(Connection connection) throws SQLException {
                PreparedStatement ps = connection.prepareStatement("insert into bag_mutaties_file (" + " id,"
                        + " date_from," + " date_to," + " content"
                        + ") values ((select coalesce(max(id),0) + 1 from bag_mutaties_file),date_trunc('day', ?::timestamp),date_trunc('day', ?::timestamp),?)"
                        + " returning id");
                ps.setDate(1, new Date(dateFrom.getTime()));
                ps.setDate(2, new Date(dateTo.getTime()));
                ps.setBytes(3, content);
                return ps;
            }
        }, new IdExtractor());
    } catch (DataAccessException e) {
        throw new DAOException(e);
    }
}

From source file:org.mifos.accounts.productdefinition.struts.actionforms.SavingsPrdActionForm.java

private void checkPreviewValidation(ActionErrors errors, HttpServletRequest request)
        throws ApplicationException {
    Date startingDate = getStartDateValue(getUserContext(request).getPreferredLocale());
    Date endingDate = getEndDateValue(getUserContext(request).getPreferredLocale());
    //validate start date
    if (startingDate != null && ((DateUtils.getDateWithoutTimeStamp(startingDate.getTime())
            .compareTo(DateUtils.getCurrentDateWithoutTimeStamp()) < 0)
            || (DateUtils.getDateWithoutTimeStamp(startingDate.getTime())
                    .compareTo(DateUtils.getCurrentDateOfNextYearWithOutTimeStamp()) > 0))) {
        addError(errors, "startDate", ProductDefinitionConstants.INVALIDSTARTDATE);
    }/*from  www .j av  a2s .  co m*/
    //validate end date
    if (startingDate != null && endingDate != null && startingDate.compareTo(endingDate) >= 0) {
        addError(errors, "endDate", ProductDefinitionConstants.INVALIDENDDATE);
    }

    validateRecommendedAmount(errors, request);
    validateMaxAmntWithdrawl(errors, request);
    validateInterestRate(errors, request);
    validateMinAmntForInt(errors, request);
    validateInterestGLCode(request, errors);
}