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:org.mifos.accounts.productdefinition.struts.actionforms.SavingsPrdActionForm.java

private void validateStartDateAgainstCurrentDate(ActionErrors errors, Date startDate) {
    if (DateUtils.getDateWithoutTimeStamp(startDate.getTime())
            .compareTo(DateUtils.getCurrentDateWithoutTimeStamp()) < 0) {
        addError(errors, "startDate", ProductDefinitionConstants.INVALIDSTARTDATE);
    }//from  w ww.j  av a  2s . c  o m
}

From source file:de.tuttas.restful.AnwesenheitsManager.java

/**
 * Lschen eines Anwesenhietseintrages Adresse
 * /api/v1/anwesenheit/{ids}/{datum}/*from www  . j a v a2  s  . co m*/
 *
 * @param ids ID des Schlers
 * @param dat Datum des Anwesenheit
 * @return Anwesenheit die gelscht wurde, oder null bei Fehler
 */
@DELETE
@Path("/{ids}/{datum}")
public Anwesenheit delAnwesenheit(@PathParam("ids") Integer ids, @PathParam("datum") Date dat) {
    Log.d("ids=" + ids + " Datum=" + dat);
    Anwesenheit a = em.find(Anwesenheit.class, new AnwesenheitId(ids, new Timestamp(dat.getTime())));
    if (a != null) {
        em.remove(a);
    } else {
        Log.d("Kann Anwesenheit nicht finden!");
    }
    return a;
}

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

/**
 * Returns a Date object representing the day after the given processDate
 * @param processDate the date to find the next day for
 * @return the next day for the given date
 *//*  www  .ja  v a  2  s.  c  o  m*/
protected Date getNextDate(Date processDate) {
    Calendar cal = Calendar.getInstance();
    cal.setTimeInMillis(processDate.getTime());
    cal.add(Calendar.DATE, 1);
    return new java.sql.Date(cal.getTimeInMillis());
}

From source file:org.lexevs.dao.database.service.valuesets.VersionableEventValueSetDefinitionService.java

@Override
public ValueSetDefinition getValueSetDefinitionByDate(String valueSetDefURI, Date date)
        throws LBRevisionException {

    if (date == null)
        return null;

    RevisionDao revisionDao = getDaoManager().getRevisionDao();

    String revisionId = revisionDao.getRevisionIdForDate(new Timestamp(date.getTime()));

    if (revisionId == null)
        return null;

    ValueSetDefinitionDao valueSetDefDao = this.getDaoManager().getCurrentValueSetDefinitionDao();

    return valueSetDefDao.getValueSetDefinitionByRevision(valueSetDefURI, revisionId);
}

From source file:com.rsmart.kuali.kfs.cr.document.service.impl.GlTransactionServiceImpl.java

/**
 * Generate GlPendingTransaction//from   w  w w. j a  va2s .  co  m
 * 
 * @param paymentGroup
 * @param financialDocumentTypeCode
 * @param stale
 */
private void generateGlPendingTransaction(PaymentGroup paymentGroup, String financialDocumentTypeCode,
        boolean stale) {
    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()));
        glPendingTransaction
                .setFdocRefTypCd(paymentAccountDetail.getPaymentDetail().getFinancialDocumentTypeCode());
        glPendingTransaction
                .setFsRefOriginCd(paymentAccountDetail.getPaymentDetail().getFinancialSystemOriginCode());
        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.setSubAccountNumber(paymentAccountDetail.getSubAccountNbr());
        glPendingTransaction.setChartOfAccountsCode(paymentAccountDetail.getFinChartCode());
        glPendingTransaction.setFdocNbr(paymentGroup.getDisbursementNbr().toString());

        // Set doc type and origin code
        glPendingTransaction.setFinancialDocumentTypeCode(financialDocumentTypeCode);
        glPendingTransaction.setFsOriginCd(CRConstants.CR_FDOC_ORIGIN_CODE);

        String clAcct = parameterService.getParameterValueAsString(CheckReconciliationImportStep.class,
                CRConstants.CLEARING_ACCOUNT);
        String obCode = parameterService.getParameterValueAsString(CheckReconciliationImportStep.class,
                CRConstants.CLEARING_OBJECT_CODE);
        String coaCode = parameterService.getParameterValueAsString(CheckReconciliationImportStep.class,
                CRConstants.CLEARING_COA);

        // Use clearing parameters if stale
        String accountNbr = stale ? clAcct : paymentAccountDetail.getAccountNbr();
        String finObjectCode = stale ? obCode : paymentAccountDetail.getFinObjectCode();
        String finCoaCd = stale ? coaCode : paymentAccountDetail.getFinChartCode();

        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.setAccountNumber(accountNbr);
            glPendingTransaction.setChartOfAccountsCode(finCoaCd);
            glPendingTransaction.setFinancialObjectCode(
                    offsetDefinition != null ? offsetDefinition.getFinancialObjectCode() : finObjectCode);
            glPendingTransaction.setFinancialSubObjectCode(KFSConstants.getDashFinancialSubObjectCode());
        } else {
            glPendingTransaction.setAccountNumber(accountNbr);
            glPendingTransaction.setChartOfAccountsCode(finCoaCd);
            glPendingTransaction.setFinancialObjectCode(finObjectCode);
            glPendingTransaction.setFinancialSubObjectCode(paymentAccountDetail.getFinSubObjectCode());
        }

        glPendingTransaction.setProjectCd(paymentAccountDetail.getProjectCode());

        if (paymentAccountDetail.getAccountNetAmount().bigDecimalValue().signum() >= 0) {
            glPendingTransaction.setDebitCrdtCd(KFSConstants.GL_CREDIT_CODE);
        } else {
            glPendingTransaction.setDebitCrdtCd(KFSConstants.GL_DEBIT_CODE);
        }
        glPendingTransaction.setAmount(paymentAccountDetail.getAccountNetAmount().abs());

        String trnDesc;

        String payeeName = paymentGroup.getPayeeName();
        trnDesc = payeeName.length() > 40 ? payeeName.substring(0, 40) : StringUtils.rightPad(payeeName, 40);

        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();
    }

}

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

private void validateStartDate(ActionErrors errors, java.util.Date oldStartDate, Date changedStartDate) {
    if (DateUtils.getDateWithoutTimeStamp(oldStartDate.getTime())
            .compareTo(DateUtils.getCurrentDateWithoutTimeStamp()) <= 0
            && (changedStartDate != null && DateUtils.getDateWithoutTimeStamp(oldStartDate.getTime())
                    .compareTo(DateUtils.getDateWithoutTimeStamp(changedStartDate.getTime())) != 0)) {
        addError(errors, "startDate", ProductDefinitionConstants.STARTDATEUPDATEEXCEPTION);

    } else if (changedStartDate != null && DateUtils.getDateWithoutTimeStamp(oldStartDate.getTime())
            .compareTo(DateUtils.getCurrentDateWithoutTimeStamp()) > 0) {
        validateStartDateAgainstCurrentDate(errors, changedStartDate);
        validateStartDateAgainstNextYearDate(errors, changedStartDate);
    }//from ww  w  . j  av a  2s.  c  o  m

}

From source file:org.kuali.kra.award.paymentreports.awardreports.reporting.service.ReportTrackingServiceImpl.java

protected void runDateCalcuations(List<java.util.Date> dates, Award award, AwardReportTerm awardTerm,
        List<ReportTracking> reportsToSave) {
    if (dates.size() == 0 && awardTerm.getReportTrackings().size() == 0) {
        ReportTracking rt = buildReportTracking(award, awardTerm);
        awardTerm.getReportTrackings().add(rt);
    }/*from w w w . j a  v a  2 s .com*/
    /**
     * Add a new report tracking item for each date, if that date doesn't already have a report tracking item.
     */

    for (java.util.Date date : dates) {
        if (!isAwardTermDateAlreadySet(awardTerm.getReportTrackings(), date)) {
            ReportTracking rt = buildReportTracking(award, awardTerm);
            java.sql.Date sqldate = new java.sql.Date(date.getTime());
            rt.setDueDate(sqldate);
            awardTerm.getReportTrackings().add(rt);
            reportsToSave.add(rt);
        }
    }
}

From source file:com.project.implementation.ReservationImplementation.java

public ArrayList<HashMap<String, String>> calculateBill(String reservation_token, String user_name,
        Double discountDouble) {//from   www  . jav a 2s  .co m

    //check if service agent exist
    List<User> userName = userDAO.verifyUserByUserName(user_name);
    Integer user_id = userName.get(0).getUser_id();
    System.out.println("user_id: " + user_id);
    String userNameString = userName.get(0).getUser_name().toString();
    System.out.println("userNameString: " + userNameString);

    ArrayList<HashMap<String, String>> billList = new ArrayList<HashMap<String, String>>();
    HashMap<String, String> billHash = new HashMap<String, String>();

    if (user_name.equals(userNameString)) {
        //fetch reservation id
        List<Reservation> reservRecords = reservationDAO.find(reservation_token);
        Integer reservation_id = reservRecords.get(0).getReservation_id();
        System.out.println("reservation_id: " + reservation_id);
        Integer guest_id = reservRecords.get(0).getGuest_id();
        System.out.println("guest_id:: " + guest_id);
        List<Guest> emailRecord = guestDAO.findGuestEmailId(reservRecords.get(0).getGuest_id());
        String guestEmailID = emailRecord.get(0).getGuest_email();
        String guestName = emailRecord.get(0).getGuest_name();
        System.out.println("emailRecord: " + guestEmailID);
        System.out.println("guestName: " + guestName);
        System.out.println(reservRecords.size());

        System.out.println(reservRecords.get(0).getReservation_id());
        Integer s = reservRecords.get(0).getReservation_id();
        System.out.println("integer value: " + s);
        //Integer reservation_id = reservRecords.get(0).getReservation_id();

        //fetch checkin mapping table data
        ReservationDTO reservDTO = new ReservationDTO();
        reservDTO.setReservation_id(reservRecords.get(0).getReservation_id());
        List<CheckinRoomMapping> checkinMappingRecords = checkinRoomMappingDAO.findMappingForBilling(reservDTO);
        Date checkin_date = checkinMappingRecords.get(0).getCheckin_date();
        Date checkout_date = checkinMappingRecords.get(0).getCheckout_date();

        long daysStay = ((checkout_date.getTime() - checkin_date.getTime()) / MILLISECONDS_IN_DAY) + 1;//
        System.out.println("daysStay: " + daysStay);
        String noOfDaysStayed = String.valueOf(daysStay);//
        System.out.println("noOfDaysStayed: " + noOfDaysStayed);
        Double totalBill = 0.0;
        ArrayList<HashMap<String, String>> mailContent = new ArrayList<HashMap<String, String>>();
        for (int i = 0; i < checkinMappingRecords.size(); i++) {
            System.out.println("Room(" + i + ") : " + checkinMappingRecords.get(i).getRoom_no());

            Integer room_no = checkinMappingRecords.get(i).getRoom_no();
            String roomNoInString = String.valueOf(room_no);//
            System.out.println("roomNoInString: " + roomNoInString);
            RoomDTO roomDTO = new RoomDTO();
            roomDTO.setRoom_no(room_no);

            Enum<RoomType> roomType = roomDAO.findRoomType(roomDTO);
            String type = roomType.toString();//
            if (type.equalsIgnoreCase("K"))
                type = "King";
            if (type.equalsIgnoreCase("Q"))
                type = "Queen";
            if (type.equalsIgnoreCase("SK"))
                type = "Smoking - King";
            if (type.equalsIgnoreCase("SQ"))
                type = "Smoking - Queen";
            System.out.println("room type: " + type);

            //Fetch price by room type
            Double roomPrice = roomPriceDAO.getRoomPrice(roomType);//
            System.out.println("roomPrice:::" + roomPrice);
            String roomPriceString = String.valueOf(roomPrice);
            System.out.println("roomPriceString: " + roomPriceString);
            Double billPerRoom = roomPrice * daysStay;//
            String billPerRoomString = String.valueOf(billPerRoom);
            System.out.println("billPerRoomString:" + billPerRoomString);
            totalBill = totalBill + billPerRoom;

            //set hash map
            HashMap<String, String> mailBody = new HashMap<String, String>();
            mailBody.put("Room_Number", roomNoInString);
            mailBody.put("Room_Type", type);
            mailBody.put("Room_Price", roomPriceString);
            mailBody.put("NoOfDays", noOfDaysStayed);
            mailBody.put("BillPerRoom", billPerRoomString);

            mailContent.add(mailBody);
            //end hash map

            System.out.println("-------");
        }
        System.out.println("totalBill::" + totalBill);
        String templateForEmailBody = "";
        for (HashMap<String, String> h : mailContent) {
            System.out.println("room_numer" + h.get("Room_Number"));
            templateForEmailBody = templateForEmailBody + "<tr><td>" + h.get("Room_Number") + "</td><td>"
                    + h.get("Room_Type") + "</td><td>" + h.get("Room_Price") + "</td><td>" + h.get("NoOfDays")
                    + "</td><td>" + h.get("BillPerRoom") + "</td><tr><br>";

        }
        System.out.println("templateForEmailBody" + templateForEmailBody);
        Integer bill_no = guest_id;
        String bill_no_String = String.valueOf(bill_no);
        System.out.println("discount" + discountDouble);
        //String bill_no_String = String.valueOf(discountDouble);

        Double totalDiscount = (discountDouble / 100) * totalBill;
        String totalDiscountString = String.valueOf(totalDiscount);

        Double amountPayable = totalBill - totalDiscount;
        String amountPayableString = String.valueOf(amountPayable);

        //ReservationDTO res = new ReservationDTO();
        BillingDTO billingDTO = new BillingDTO();
        billingDTO.setBill_no(bill_no);
        billingDTO.setReservation_id(reservation_id);
        billingDTO.setUser_id(user_id);
        billingDTO.setDiscount(totalDiscount);
        billingDTO.setAmount(amountPayable);

        Reservation resObj = new Reservation();
        resObj.setReservation_id(reservation_id);

        User userObj = new User();
        userObj.setUser_id(user_id);

        Billing billObject = new Billing();
        billObject.setBill_no(bill_no);
        billObject.setReservation(resObj);
        billObject.setUser(userObj);
        billObject.setDiscount(totalDiscount);
        billObject.setAmount(amountPayable);

        //            try {
        //                org.apache.commons.beanutils.BeanUtils.copyProperties(billObject, billingDTO);
        //            } catch (IllegalAccessException e) {
        //                e.printStackTrace();
        //            } catch (InvocationTargetException e) {
        //                e.printStackTrace();
        //            }

        Integer billID = billingDAO.insertBillData(billObject);
        System.out.println("Bill id after Insert: " + billID);

        if (billID != null) {
            //email

            final String from = "express.minihotel@gmail.com";
            String to = guestEmailID;
            String body = "Hello " + guestName + ",<br><br>You bill details are as follows:<br>"
                    + "<table border='1' style=\"border-collapse: collapse;\"><tr>"
                    + "<td><b>Room Number</b></td>" + "<td><b>Room Type</b></td>"
                    + "<td><b>Price per day ($)</b></td>" + "<td><b>Duration of Stay (days)</b></td>"
                    + "<td><b>Bill for Room ($)</b></td></tr>" + templateForEmailBody
                    + "</table><br>Net Bill: $" + totalBill + "<br><br>" + "Discount: $" + totalDiscountString
                    + "<br></br>" + "<br/><b>Total Bill Paid($): <font color='red'>" + amountPayable
                    + "</font></b><br></br><br></br>Thank You for choosing Express Hotel.<br/><br/><i>--Express Hotel</i>";

            String subject = "Express Hotel - Bill Receipt (Receipt No : " + bill_no_String + ")";
            final String password = "Minihotel@2015";
            Properties props = new Properties();
            props.put("mail.smtp.auth", "true");
            props.put("mail.smtp.starttls.enable", "true");
            props.put("mail.smtp.host", "smtp.gmail.com");
            props.put("mail.smtp.port", "587");
            Session session = Session.getInstance(props, new javax.mail.Authenticator() {
                protected PasswordAuthentication getPasswordAuthentication() {
                    return new PasswordAuthentication(from, password);
                }
            });
            try {
                MimeMessage email = new MimeMessage(session);
                email.setFrom(new InternetAddress(from));
                email.setRecipients(javax.mail.Message.RecipientType.TO, InternetAddress.parse(to));
                email.setSubject(subject);
                email.setContent(body, "text/html");
                Transport.send(email);

            } catch (MessagingException e) {

                throw new RuntimeException(e);

            }

            //email
            billHash.put("bill_amount", amountPayableString);
            billHash.put("bill_body", body);
            billList.add(billHash);
            //return billList;
        }
    } else {
        //username doesnot exist
        billHash.put("bill_amount", "User does not exist");
        billList.add(billHash);
        //return billList;
    }

    return billList;

}

From source file:com.mss.msp.util.DateUtility.java

public Date getMySqlDate1(String date) throws ParseException {
    SimpleDateFormat sdf = new SimpleDateFormat("dd-MMM-yyyy");
    java.util.Date uDate = sdf.parse(date);
    java.sql.Date sqlDate = new java.sql.Date(uDate.getTime());

    return sqlDate;
}

From source file:de.tuttas.restful.AnwesenheitsManager.java

/**
 * Lschen einer Krankmeldung/*from   w  w w .  j  a  v  a  2s  .c o m*/
 *
 * @param ids ID des Schlers
 * @param dat Datum der Krankmeldung
 * @return Anwesenheitseintrag
 */
@DELETE
@Path("/schueler/{ids}/{datum}")
public ResultObject delKrankmeldung(@PathParam("ids") Integer ids, @PathParam("datum") Date dat) {
    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(null);
        em.merge(a);
        ro.setSuccess(true);
        ro.setMsg("Krankmeldung von " + a.getID_SCHUELER() + " am " + dat + " gelscht!");
    } 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;
}