List of usage examples for org.joda.time LocalDate now
public static LocalDate now()
ISOChronology
in the default time zone. From source file:com.axelor.studio.service.ReportPrinterService.java
License:Open Source License
/** * Root method to access the service. It process template of reportBuilder * and generate html from it. It also process fileName of report builder. * /*from ww w .j av a 2 s. c om*/ * @param reportBuilder * ReportBuilder to process; * @param recordId * Id of record to process. * @return Generated html report and processed file name.. */ public String[] getHtml(ReportBuilder reportBuilder, Long recordId) { try { String model = reportBuilder.getMetaModel().getFullName(); @SuppressWarnings("unchecked") Model entity = JPA.find((Class<Model>) Class.forName(model), recordId); StringTemplates strTemplate = new StringTemplates('$', '$'); String text = getTemplate(reportBuilder); if (text == null) { return new String[] { I18n.get("No template found") }; } String fileName = reportBuilder.getFileName(); fileName = fileName.replace("$TODAY$", LocalDate.now().toString("ddMMYYYY")); fileName = fileName.replace("$NOW$", LocalDateTime.now().toString("ddMMYYYYHHmm")); Template template = strTemplate.fromText(fileName); fileName = template.make(entity).render(); template = strTemplate.fromText(text); return new String[] { fileName, template.make(entity).render() }; } catch (ClassNotFoundException e) { e.printStackTrace(); } return new String[] { I18n.get("Error in printing") }; }
From source file:com.bgh.myopeninvoice.jsf.jsfbeans.InvoiceBean.java
License:Apache License
private void recalculateBasedOnSelection() { boolean reset = false; if (selectedInvoiceEntity.getContractsByCompanyContractTo() != null) { selectedInvoiceEntity.setRate(selectedInvoiceEntity.getContractsByCompanyContractTo().getRate()); selectedInvoiceEntity/* w w w .j a va 2s . c om*/ .setRateUnit(selectedInvoiceEntity.getContractsByCompanyContractTo().getRateUnit()); selectedInvoiceEntity.setCcyId(selectedInvoiceEntity.getContractsByCompanyContractTo().getCcyId()); selectedInvoiceEntity.setCurrencyByCcyId( selectedInvoiceEntity.getContractsByCompanyContractTo().getCurrencyByCcyId()); if (StringUtils.isBlank(selectedInvoiceEntity.getTitle())) { selectedInvoiceEntity.setTitle(selectedInvoiceEntity.getCompanyContactByCompanyContactFrom() .getCompaniesByCompanyId().getShortName() + "-" + LocalDate.now().getYear() + "-" + invoiceDAO.getInvoiceCounterSeq()); } } else { reset = true; } if (reset) { selectedInvoiceEntity.setRate(new BigDecimal(0)); selectedInvoiceEntity.setRateUnit(null); selectedInvoiceEntity.setCcyId(null); selectedInvoiceEntity.setCurrencyByCcyId(null); selectedInvoiceEntity.setTitle(""); } }
From source file:com.creditcloud.carinsurance.local.CarInsuranceFeeLocalBean.java
/** * ?/* www .j a v a 2s . c o m*/ * @param repayment * @return */ public BigDecimal overdueFee(CarInsuranceRepayment repayment) { if (repayment == null) { return BigDecimal.ZERO; } if (LocalDate.now().toDate().compareTo(repayment.getDueDate()) <= 0) { return BigDecimal.ZERO; } BigDecimal days = BigDecimal.ZERO; // if (repayment.getRepayDate() != null) { long repayTime = repayment.getRepayDate().getTime(); long dueTime = repayment.getDueDate().getTime(); days = BigDecimal.valueOf((repayTime - dueTime) / DateUtils.MILLIS_PER_DAY); if (days.compareTo(BigDecimal.ZERO) < 0) { return BigDecimal.ZERO; } } else { long nowTime = LocalDate.now().plusDays(1).toDate().getTime(); long dueTime = repayment.getDueDate().getTime(); days = BigDecimal.valueOf((nowTime - dueTime) / DateUtils.MILLIS_PER_DAY); } BigDecimal penaltyAmount = BigDecimal.ZERO; //??? Fee overduePenaltyFee = configManager.getCarInsuranceConfig().getPenaltyFee(); penaltyAmount = FeeUtils.calculate(overduePenaltyFee, repayment.getAmountPrincipal()).multiply(days) .setScale(NumberConstant.DEFAULT_SCALE, NumberConstant.ROUNDING_MODE); return penaltyAmount; }
From source file:com.einzig.ipst2.database.DatabaseInterface.java
License:Open Source License
/** * Get a Vector of all accepted portals which went live after a certain date * * @param fromDate Date to start searching from * @return Vector of all accepted portals which went live after a certain date *///ww w . j a v a 2 s .c om public Vector<PortalAccepted> getAcceptedByResponseDate(LocalDate fromDate, boolean seerOnly) { return getAcceptedByResponseDate(fromDate, LocalDate.now(), seerOnly); }
From source file:com.einzig.ipst2.database.DatabaseInterface.java
License:Open Source License
/** * Get a Vector of all accepted portals which were submitted after a certain date * * @param fromDate Date to start searching from * @return Vector of all accepted portals which were submitted after a certain date *///from w w w. j a va2 s. c o m public Vector<PortalAccepted> getAcceptedBySubmissionDate(LocalDate fromDate, boolean seerOnly) { return getAcceptedBySubmissionDate(fromDate, LocalDate.now(), seerOnly); }
From source file:com.einzig.ipst2.database.DatabaseInterface.java
License:Open Source License
/** * Get the number of portals in a table since fromDate * * @param table Table in the database * @param dateKey Either COLUMN_DATE_SUBMITTED or COLUMN_DATE_RESPONDED * @param fromDate Date to start searching from * @return number of portals in a table since date *///from w w w . j a va 2 s. co m private long getCountByDate(String table, String dateKey, LocalDate fromDate, boolean seerOnly) { return getCountByDate(table, dateKey, fromDate, LocalDate.now(), seerOnly); }
From source file:com.einzig.ipst2.database.DatabaseInterface.java
License:Open Source License
/** * Get all pending portal submissions which were submitted since fromDate * * @param fromDate Date to start searching from * @return Vector of all pending portals which were submitted after a fromDate *///from ww w . j a v a 2s. c o m public Vector<PortalSubmission> getPendingByDate(LocalDate fromDate, boolean seerOnly) { return getPendingByDate(fromDate, LocalDate.now(), seerOnly); }
From source file:com.einzig.ipst2.database.DatabaseInterface.java
License:Open Source License
/** * Get a Vector of all rejected portals which went live after a certain date * * @param fromDate Date to start searching from * @return Vector of all rejected portals which went live after a certain date *//*from w w w . j a v a2 s .co m*/ public Vector<PortalRejected> getRejectedByResponseDate(LocalDate fromDate, boolean seerOnly) { return getRejectedByResponseDate(fromDate, LocalDate.now(), seerOnly); }
From source file:com.einzig.ipst2.database.DatabaseInterface.java
License:Open Source License
/** * Get a Vector of all rejected portals which were submitted after a certain date * * @param fromDate Date to start searching from * @return Vector of all rejected portals which were submitted after a certain date *///from w w w. j a va 2s.c om public Vector<PortalRejected> getRejectedBySubmissionDate(LocalDate fromDate, boolean seerOnly) { return getRejectedBySubmissionDate(fromDate, LocalDate.now(), seerOnly); }
From source file:com.einzig.ipst2.database.PortalBuilder.java
License:Open Source License
LocalDate parseDate(String dateString) { try {//from w w w.ja va2 s. co m return DATE_FORMATTER.parseLocalDate(dateString); } catch (IllegalArgumentException e) { return LocalDate.now(); } }