List of usage examples for java.sql Date getTime
public long getTime()
From source file:org.eclipse.birt.data.oda.mongodb.impl.MDbResultSet.java
public Time getTime(String columnName) throws OdaException { Date dateValue = getDate(columnName); if (dateValue == null) return null; return new Time(dateValue.getTime()); }
From source file:org.kuali.ole.pdp.service.impl.PendingTransactionServiceImpl.java
/** * Populates and stores a new GLPE for each account detail in the payment group. * /* w w w . j av a2 s. c o m*/ * @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 */ 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(OLEConstants.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(OLEConstants.getDashFinancialSubObjectCode()); } else { glPendingTransaction.setFinancialObjectCode(paymentAccountDetail.getFinObjectCode()); glPendingTransaction.setFinancialSubObjectCode(paymentAccountDetail.getFinSubObjectCode()); } glPendingTransaction.setProjectCd(paymentAccountDetail.getProjectCode()); if (paymentAccountDetail.getPaymentDetail().getNetPaymentAmount().bigDecimalValue().signum() >= 0) { glPendingTransaction .setDebitCrdtCd(reversal ? OLEConstants.GL_CREDIT_CODE : OLEConstants.GL_DEBIT_CODE); } else { glPendingTransaction .setDebitCrdtCd(reversal ? OLEConstants.GL_DEBIT_CODE : OLEConstants.GL_CREDIT_CODE); } glPendingTransaction.setAmount(paymentAccountDetail.getAccountNetAmount().abs()); String trnDesc = ""; 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:com.mss.msp.util.DateUtility.java
public Timestamp strToTimeStampObj(String dateAccessor) { try {// ww w . ja va 2 s . c o m int indDash1 = dateAccessor.indexOf("/", 0); int indDash2 = dateAccessor.indexOf("/", indDash1 + 1); if (indDash1 == -1 || indDash2 == -1) { int _ind1 = dateAccessor.indexOf("-", 0); int _ind2 = dateAccessor.indexOf("-", _ind1 + 1); //returns index of " - " in given String Object if (_ind1 == 4 && (_ind2 == 7 || _ind2 == 6)) { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); java.util.Date date = sdf.parse(dateAccessor); dateTimestampObj = new java.sql.Timestamp(date.getTime()); } } else { SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd"); java.util.Date date = sdf.parse(usTimeStampToSqlTimeStamp(dateAccessor)); dateTimestampObj = new java.sql.Timestamp(date.getTime()); } } catch (ParseException pe) { System.out.println("ParseException in" + pe); } return dateTimestampObj; }
From source file:org.kuali.kfs.module.cam.document.service.impl.AssetGlobalServiceImpl.java
/** * Creates a new Asset appropriate for either create new or separate. This does not create the payments for this asset. * * @param assetGlobal containing data for the asset to be created * @param assetGlobalDetail containing data for the asset to be created * @param separate indicating whether this is a separate and asset or not * @return set of assets appropriate for this creation without payments *///from w w w . j a va2s . c o m protected Asset setupAsset(AssetGlobal assetGlobal, AssetGlobalDetail assetGlobalDetail, boolean separate) { Asset asset = new Asset(assetGlobal, assetGlobalDetail, separate); KualiDecimalUtils kualiDecimalUtils = new KualiDecimalUtils(); // set financialObjectSubTypeCode per first payment entry if one exists if (!assetGlobal.getAssetPaymentDetails().isEmpty() && ObjectUtils.isNotNull(assetGlobal.getAssetPaymentDetails().get(0).getObjectCode())) { AssetPaymentDetail assetPaymentDetail = assetGlobal.getAssetPaymentDetails().get(0); ObjectCode objectCode = objectCodeService.getByPrimaryIdForCurrentYear( assetPaymentDetail.getChartOfAccountsCode(), assetPaymentDetail.getFinancialObjectCode()); asset.setFinancialObjectSubTypeCode(objectCode.getFinancialObjectSubTypeCode()); } // create off campus location for each asset only if it was filled in boolean offCampus = StringUtils.isNotBlank(assetGlobalDetail.getOffCampusName()) || StringUtils.isNotBlank(assetGlobalDetail.getOffCampusAddress()) || StringUtils.isNotBlank(assetGlobalDetail.getOffCampusCityName()) || StringUtils.isNotBlank(assetGlobalDetail.getOffCampusStateCode()) || StringUtils.isNotBlank(assetGlobalDetail.getOffCampusZipCode()) || StringUtils.isNotBlank(assetGlobalDetail.getOffCampusCountryCode()); if (offCampus) { setupAssetLocationOffCampus(assetGlobalDetail, asset); } // set specific values for new assets if document is Asset Separate if (separate) { double separateRatio = assetGlobalDetail.getSeparateSourceAmount().doubleValue() / assetGlobal.getSeparateSourceCapitalAsset().getTotalCostAmount().doubleValue(); asset.setSalvageAmount(kualiDecimalUtils .safeMultiply(assetGlobal.getSeparateSourceCapitalAsset().getSalvageAmount(), separateRatio)); asset.setReplacementAmount(kualiDecimalUtils.safeMultiply( assetGlobal.getSeparateSourceCapitalAsset().getReplacementAmount(), separateRatio)); asset.setFabricationEstimatedTotalAmount(kualiDecimalUtils.safeMultiply( assetGlobal.getSeparateSourceCapitalAsset().getFabricationEstimatedTotalAmount(), separateRatio)); Date lastInventoryDate = assetGlobal.getLastInventoryDate(); if (lastInventoryDate != null) { asset.setLastInventoryDate(new Timestamp(lastInventoryDate.getTime())); } } return asset; }
From source file:de.tuttas.restful.AnwesenheitsManager.java
@PUT @Path("/schueler/{ids}/{datum}") public ResultObject setKrankmeldung(@PathParam("ids") Integer ids, @PathParam("datum") Date dat, String krankmeldung) {// ww w .j a va 2 s . c om Log.d("ids=" + ids + " Datum=" + dat); ResultObject ro = new ResultObject(); Anwesenheit a = em.find(Anwesenheit.class, new AnwesenheitId(ids, new Timestamp(dat.getTime()))); if (a != null) { a.setKRANKMELDUNG(krankmeldung); em.merge(a); ro.setSuccess(true); ro.setMsg("Krankmeldung von Schler mit ID " + a.getID_SCHUELER() + " am " + dat + " hinzugefgt"); } else { Log.d("Kann Anwesenheit nicht finden!"); ro.setSuccess(false); ro.setMsg("Kann keinen Anwesenheitseintrag vom Schler mit ID " + ids + " am " + dat + " finden!"); } return ro; }
From source file:com.ar.hotwiredautorepairshop.beans.MainBean.java
public Integer calculateAge(String socialSecurityNumber) { socialSecurityNumber = socialSecurityNumber.substring(0, 8); java.util.Date dateParsed = new java.util.Date(); try {// w w w . ja v a2s . c o m dateParsed = new SimpleDateFormat("yyyyMMdd").parse(socialSecurityNumber); } catch (ParseException e) { } Date customerDate = new Date(dateParsed.getTime()); Calendar dateOfBirth = Calendar.getInstance(); dateOfBirth.setTime(customerDate); Calendar today = Calendar.getInstance(); int age = today.get(Calendar.YEAR) - dateOfBirth.get(Calendar.YEAR); if (today.get(Calendar.MONTH) < dateOfBirth.get(Calendar.MONTH)) { age--; } else if (today.get(Calendar.MONTH) == dateOfBirth.get(Calendar.MONTH) && today.get(Calendar.DAY_OF_MONTH) < dateOfBirth.get(Calendar.DAY_OF_MONTH)) { age--; } return age; }
From source file:org.kuali.kra.award.paymentreports.awardreports.reporting.service.ReportTrackingServiceImpl.java
private boolean isAwardTermDateAlreadySet(List<ReportTracking> reportTrackings, java.util.Date date) { boolean retVal = false; if (date == null && reportTrackings.size() > 0) { retVal = true;/*from w w w.j av a 2 s.co m*/ } if (!retVal) { for (ReportTracking rt : reportTrackings) { if (rt.getDueDate() != null && rt.getDueDate().getTime() == date.getTime()) { retVal = true; } } } return retVal; }
From source file:org.apache.sqoop.mapreduce.hcat.SqoopHCatImportHelper.java
private Object converDateTypes(Object val, HCatFieldSchema hfs) { HCatFieldSchema.Type hfsType = hfs.getType(); Date d; Time t;//from ww w. j a v a 2s .co m Timestamp ts; if (val instanceof java.sql.Date) { d = (Date) val; if (hfsType == HCatFieldSchema.Type.DATE) { return d; } else if (hfsType == HCatFieldSchema.Type.TIMESTAMP) { return new Timestamp(d.getTime()); } else if (hfsType == HCatFieldSchema.Type.BIGINT) { return (d.getTime()); } else if (hfsType == HCatFieldSchema.Type.STRING) { return val.toString(); } else if (hfsType == HCatFieldSchema.Type.VARCHAR) { VarcharTypeInfo vti = (VarcharTypeInfo) hfs.getTypeInfo(); HiveVarchar hvc = new HiveVarchar(val.toString(), vti.getLength()); return hvc; } else if (hfsType == HCatFieldSchema.Type.CHAR) { CharTypeInfo cti = (CharTypeInfo) hfs.getTypeInfo(); HiveChar hChar = new HiveChar(val.toString(), cti.getLength()); return hChar; } } else if (val instanceof java.sql.Time) { t = (Time) val; if (hfsType == HCatFieldSchema.Type.DATE) { return new Date(t.getTime()); } else if (hfsType == HCatFieldSchema.Type.TIMESTAMP) { return new Timestamp(t.getTime()); } else if (hfsType == HCatFieldSchema.Type.BIGINT) { return ((Time) val).getTime(); } else if (hfsType == HCatFieldSchema.Type.STRING) { return val.toString(); } else if (hfsType == HCatFieldSchema.Type.VARCHAR) { VarcharTypeInfo vti = (VarcharTypeInfo) hfs.getTypeInfo(); HiveVarchar hvc = new HiveVarchar(val.toString(), vti.getLength()); return hvc; } else if (hfsType == HCatFieldSchema.Type.CHAR) { CharTypeInfo cti = (CharTypeInfo) hfs.getTypeInfo(); HiveChar hChar = new HiveChar(val.toString(), cti.getLength()); return hChar; } } else if (val instanceof java.sql.Timestamp) { ts = (Timestamp) val; if (hfsType == HCatFieldSchema.Type.DATE) { return new Date(ts.getTime()); } else if (hfsType == HCatFieldSchema.Type.TIMESTAMP) { return ts; } else if (hfsType == HCatFieldSchema.Type.BIGINT) { return ts.getTime(); } else if (hfsType == HCatFieldSchema.Type.STRING) { return val.toString(); } else if (hfsType == HCatFieldSchema.Type.VARCHAR) { VarcharTypeInfo vti = (VarcharTypeInfo) hfs.getTypeInfo(); HiveVarchar hvc = new HiveVarchar(val.toString(), vti.getLength()); return hvc; } else if (hfsType == HCatFieldSchema.Type.CHAR) { CharTypeInfo cti = (CharTypeInfo) hfs.getTypeInfo(); HiveChar hc = new HiveChar(val.toString(), cti.getLength()); return hc; } } return null; }
From source file:de.tuttas.restful.AnwesenheitsManager.java
/** * Anwesenheit einer Klasse an einem bestimmten Tag abfragen Adresse * /api/v1/anwesenheit/{Name der Klasse}/{Datum} * * @param kl Name der Klasse/* w ww. ja v a2 s .com*/ * @param from Das Datum * @return Liste von Anwesenheitsobjekten */ @GET @Path("/{klasse}/{from}") public List<AnwesenheitObjekt> getAnwesenheit(@PathParam("klasse") String kl, @PathParam("from") Date from) { Calendar cal = Calendar.getInstance(); cal.set(Calendar.HOUR_OF_DAY, 0); cal.set(Calendar.MINUTE, 0); cal.set(Calendar.SECOND, 0); cal.set(Calendar.MILLISECOND, 0); Date d = new Date(from.getTime() + 1000 * 60 * 60 * 24 - 1); Log.d("Webservice Anwesenheit GET klasse=" + kl + " from=" + from + " to=" + d); TypedQuery<AnwesenheitEintrag> query = em.createNamedQuery("findAnwesenheitbyKlasse", AnwesenheitEintrag.class); query.setParameter("paramKName", kl); query.setParameter("paramFromDate", from); query.setParameter("paramToDate", d); List<AnwesenheitEintrag> anwesenheit = query.getResultList(); Query qb = em.createNamedQuery("findBemerkungbyDate"); qb.setParameter("paramFromDate", from); qb.setParameter("paramToDate", d); List<String> ids = new ArrayList<>(); for (AnwesenheitEintrag ae : anwesenheit) { ids.add("" + ae.getID_SCHUELER()); } List<Bemerkung> bemerkungen = null; qb.setParameter("idList", ids); if (ids.size() > 0) { bemerkungen = qb.getResultList(); Log.d("Result List Bemerkunken:" + bemerkungen); } return getData(anwesenheit, bemerkungen); }
From source file:org.ojbc.intermediaries.sn.dao.SubscriptionSearchQueryDAO.java
/** * Create a subscription (or update an existing one) given the input parameters * @param subscriptionSystemId/*from w w w.ja va2s. c om*/ * @param topic * @param startDateString * @param endDateString * @param subjectIds * @param emailAddresses * @param offenderName * @param subscribingSystemId * @param subscriptionQualifier * @param reasonCategoryCode * @param subscriptionOwner * @return the ID of the created (or updated) subscription */ public Number subscribe(String subscriptionSystemId, String topic, String startDateString, String endDateString, Map<String, String> subjectIds, Set<String> emailAddresses, String offenderName, String subscribingSystemId, String subscriptionQualifier, String reasonCategoryCode, String subscriptionOwner, LocalDate creationDateTime, String agencyCaseNumber) { Number ret = null; log.debug("Entering subscribe method"); // Use the current time as the start date Date startDate = null; Date endDate = null; // If start date is not provided in the subscription message, use current date if (StringUtils.isNotBlank(startDateString)) { // Create SQL date from the end date string SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd"); try { java.util.Date utilStartDate = formatter.parse(startDateString.trim()); startDate = new Date(utilStartDate.getTime()); } catch (ParseException e) { throw new RuntimeException(e); } } else { startDate = new Date(System.currentTimeMillis()); } // Many subscription message will not have end dates so we will need to // allow nulls if (StringUtils.isNotBlank(endDateString)) { // Create SQL date from the end date string SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd"); try { java.util.Date utilEndDate = formatter.parse(endDateString.trim()); endDate = new Date(utilEndDate.getTime()); } catch (ParseException e) { throw new RuntimeException(e); } } java.util.Date creationDate = creationDateTime.toDateTimeAtStartOfDay().toDate(); log.debug("Start Date String: " + startDateString); log.debug("End Date String: " + endDateString); log.debug("System Name: " + subscribingSystemId); log.debug("Subscription System ID: " + subscriptionSystemId); log.info("\n\n\n reasonCategoryCode = " + reasonCategoryCode + "\n\n\n"); if (StringUtils.isEmpty(reasonCategoryCode)) { log.warn("\n\n\n reasonCategoryCode empty, so inserting null into db \n\n\n"); reasonCategoryCode = null; } String fullyQualifiedTopic = NotificationBrokerUtils.getFullyQualifiedTopic(topic); List<Subscription> subscriptions = getSubscriptions(subscriptionSystemId, fullyQualifiedTopic, subjectIds, subscribingSystemId, subscriptionOwner); // No Record exist, insert a new one if (subscriptions.size() == 0) { log.debug("No subscriptions exist, inserting new one"); log.debug("Inserting row into subscription table"); KeyHolder keyHolder = new GeneratedKeyHolder(); this.jdbcTemplate.update(buildPreparedInsertStatementCreator( "insert into subscription (topic, startDate, endDate, subscribingSystemIdentifier, subscriptionOwner, subjectName, active, subscription_category_code, lastValidationDate, agency_case_number) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", new Object[] { fullyQualifiedTopic.trim(), startDate, endDate, subscribingSystemId.trim(), subscriptionOwner, offenderName.trim(), 1, reasonCategoryCode, creationDate, agencyCaseNumber }), keyHolder); ret = keyHolder.getKey(); log.debug("Inserting row into notification_mechanism table"); for (String emailAddress : emailAddresses) { this.jdbcTemplate.update( "insert into notification_mechanism (subscriptionId, notificationMechanismType, notificationAddress) values (?,?,?)", keyHolder.getKey(), NotificationConstants.NOTIFICATION_MECHANISM_EMAIL, emailAddress); } log.debug("Inserting row(s) into subscription_subject_identifier table"); for (Map.Entry<String, String> entry : subjectIds.entrySet()) { this.jdbcTemplate.update( "insert into subscription_subject_identifier (subscriptionId, identifierName, identifierValue) values (?,?,?)", keyHolder.getKey(), entry.getKey(), entry.getValue()); } } // A subscriptions exists, let's update it if (subscriptions.size() == 1) { log.debug("Ensure that SIDs match before updating subscription"); log.debug("Updating existing subscription"); log.debug("Subject Id Map: " + subjectIds); log.debug("Email Addresses: " + emailAddresses.toString()); log.debug("Updating row in subscription table"); this.jdbcTemplate.update( "update subscription set topic=?, startDate=?, endDate=?, subjectName=?, active=1, subscriptionOwner=?, lastValidationDate=? where id=?", new Object[] { fullyQualifiedTopic.trim(), startDate, endDate, offenderName.trim(), subscriptionOwner, creationDate, subscriptions.get(0).getId() }); log.debug("Updating row in notification_mechanism table"); // We will delete all email addresses associated with the subscription and re-add them this.jdbcTemplate.update("delete from notification_mechanism where subscriptionId = ?", new Object[] { subscriptions.get(0).getId() }); for (String emailAddress : emailAddresses) { this.jdbcTemplate.update( "insert into notification_mechanism (subscriptionId, notificationMechanismType, notificationAddress) values (?,?,?)", subscriptions.get(0).getId(), NotificationConstants.NOTIFICATION_MECHANISM_EMAIL, emailAddress); } ret = subscriptions.get(0).getId(); } if (ret != null && CIVIL_SUBSCRIPTION_REASON_CODE.equals(reasonCategoryCode)) { subscribeIdentificationTransaction(ret, agencyCaseNumber, endDateString); } return ret; }