List of usage examples for org.joda.time LocalDate toString
@ToString
public String toString()
From source file:com.gst.portfolio.loanaccount.serialization.LoanEventApiJsonValidator.java
License:Apache License
public void validateRepaymentDateWithMeetingDate(final LocalDate repaymentDate, final CalendarInstance calendarInstance) { if (null != calendarInstance) { final Calendar calendar = calendarInstance.getCalendar(); if (calendar != null && repaymentDate != null) { // Disbursement date should fall on a meeting date if (!CalendarUtils.isValidRedurringDate(calendar.getRecurrence(), calendar.getStartDateLocalDate(), repaymentDate)) {/* w w w .j a v a 2 s .c o m*/ final String errorMessage = "Transaction date '" + repaymentDate.toString() + "' does not fall on a meeting date."; throw new NotValidRecurringDateException("loan.transaction.date", errorMessage, repaymentDate.toString(), calendar.getTitle()); } } } }
From source file:com.gst.portfolio.loanaccount.service.LoanApplicationWritePlatformServiceJpaRepositoryImpl.java
License:Apache License
private void validateSubmittedOnDate(final Loan loan) { final LocalDate startDate = loan.loanProduct().getStartDate(); final LocalDate closeDate = loan.loanProduct().getCloseDate(); final LocalDate expectedFirstRepaymentOnDate = loan.getExpectedFirstRepaymentOnDate(); final LocalDate submittedOnDate = loan.getSubmittedOnDate(); String defaultUserMessage = ""; if (startDate != null && submittedOnDate.isBefore(startDate)) { defaultUserMessage = "submittedOnDate cannot be before the loan product startDate."; throw new LoanApplicationDateException("submitted.on.date.cannot.be.before.the.loan.product.start.date", defaultUserMessage, submittedOnDate.toString(), startDate.toString()); }/*from ww w .j av a 2 s. c o m*/ if (closeDate != null && submittedOnDate.isAfter(closeDate)) { defaultUserMessage = "submittedOnDate cannot be after the loan product closeDate."; throw new LoanApplicationDateException("submitted.on.date.cannot.be.after.the.loan.product.close.date", defaultUserMessage, submittedOnDate.toString(), closeDate.toString()); } if (expectedFirstRepaymentOnDate != null && submittedOnDate.isAfter(expectedFirstRepaymentOnDate)) { defaultUserMessage = "submittedOnDate cannot be after the loans expectedFirstRepaymentOnDate."; throw new LoanApplicationDateException( "submitted.on.date.cannot.be.after.the.loan.expected.first.repayment.date", defaultUserMessage, submittedOnDate.toString(), expectedFirstRepaymentOnDate.toString()); } }
From source file:com.gst.portfolio.loanproduct.service.LoanProductWritePlatformServiceJpaRepositoryImpl.java
License:Apache License
private void validateInputDates(final JsonCommand command) { final LocalDate startDate = command.localDateValueOfParameterNamed("startDate"); final LocalDate closeDate = command.localDateValueOfParameterNamed("closeDate"); if (startDate != null && closeDate != null) { if (closeDate.isBefore(startDate)) { throw new LoanProductDateException(startDate.toString(), closeDate.toString()); }//from w w w . j a v a2 s . c o m } }
From source file:com.gst.portfolio.savings.domain.SavingsAccount.java
License:Apache License
public void reassignSavingsOfficer(final Staff newSavingsOfficer, final LocalDate assignmentDate) { final SavingsOfficerAssignmentHistory latestHistoryRecord = findLatestIncompleteHistoryRecord(); final SavingsOfficerAssignmentHistory lastAssignmentRecord = findLastAssignmentHistoryRecord( newSavingsOfficer);//from ww w . j ava2 s . c o m // assignment date should not be less than savings account submitted // date if (isSubmittedOnDateAfter(assignmentDate)) { final String errorMessage = "The Savings Officer assignment date (" + assignmentDate.toString() + ") cannot be before savings submitted date (" + getSubmittedOnDate().toString() + ")."; throw new SavingsOfficerAssignmentDateException("cannot.be.before.savings.submitted.date", errorMessage, assignmentDate, getSubmittedOnDate()); } else if (lastAssignmentRecord != null && lastAssignmentRecord.isEndDateAfter(assignmentDate)) { final String errorMessage = "The Savings Officer assignment date (" + assignmentDate + ") cannot be before previous Savings Officer unassigned date (" + lastAssignmentRecord.getEndDate() + ")."; throw new SavingsOfficerAssignmentDateException("cannot.be.before.previous.unassignement.date", errorMessage, assignmentDate, lastAssignmentRecord.getEndDate()); } else if (DateUtils.getLocalDateOfTenant().isBefore(assignmentDate)) { final String errorMessage = "The Savings Officer assignment date (" + assignmentDate + ") cannot be in the future."; throw new SavingsOfficerAssignmentDateException("cannot.be.a.future.date", errorMessage, assignmentDate); } else if (latestHistoryRecord != null && this.savingsOfficer.identifiedBy(newSavingsOfficer)) { latestHistoryRecord.updateStartDate(assignmentDate); } else if (latestHistoryRecord != null && latestHistoryRecord.matchesStartDateOf(assignmentDate)) { latestHistoryRecord.updateSavingsOfficer(newSavingsOfficer); this.savingsOfficer = newSavingsOfficer; } else if (latestHistoryRecord != null && latestHistoryRecord.hasStartDateBefore(assignmentDate)) { final String errorMessage = "Savings account with identifier " + getId() + " was already assigned before date " + assignmentDate; throw new SavingsOfficerAssignmentDateException("is.before.last.assignment.date", errorMessage, getId(), assignmentDate); } else { if (latestHistoryRecord != null) { // savings officer correctly changed from previous savings // officer to // new savings officer latestHistoryRecord.updateEndDate(assignmentDate); } this.savingsOfficer = newSavingsOfficer; if (isNotSubmittedAndPendingApproval()) { final SavingsOfficerAssignmentHistory savingsOfficerAssignmentHistory = SavingsOfficerAssignmentHistory .createNew(this, this.savingsOfficer, assignmentDate); this.savingsOfficerHistory.add(savingsOfficerAssignmentHistory); } } }
From source file:com.helger.masterdata.postal.PostalCodeListReader.java
License:Apache License
public void readFromFile(@Nonnull final IReadableResource aRes) { ValueEnforcer.notNull(aRes, "Resource"); final IMicroDocument aDoc = MicroReader.readMicroXML(aRes); if (aDoc == null) throw new IllegalArgumentException("Passed resource is not an XML file: " + aRes); final IMicroElement eBody = aDoc.getDocumentElement().getFirstChildElement(ELEMENT_BODY); if (eBody == null) throw new IllegalArgumentException("Missing body element in file " + aRes); final LocalDate aNow = PDTFactory.getCurrentLocalDate(); // Read all countries for (final IMicroElement eCountry : eBody.getAllChildElements(ELEMENT_COUNTRY)) { final String sCountryName = eCountry.getAttributeValue(ATTR_NAME); final String sISO = eCountry.getAttributeValue(ATTR_ISO); final PostalCodeCountry aCountry = new PostalCodeCountry(sISO); // Read all postal code definitions for (final IMicroElement ePostalCode : eCountry.getAllChildElements(ELEMENT_POSTALCODES)) { final String sValidFrom = ePostalCode.getAttributeValue(ATTR_VALIDFROM); final LocalDate aValidFrom = sValidFrom == null ? null : ISODateTimeFormat.date().parseLocalDate(sValidFrom); final String sValidTo = ePostalCode.getAttributeValue(ATTR_VALIDTO); final LocalDate aValidTo = sValidTo == null ? null : ISODateTimeFormat.date().parseLocalDate(sValidTo); if (aValidFrom != null && aValidFrom.isAfter(aNow)) { MasterdataLogger.getInstance().info("Ignoring some postal code definitions of " + sCountryName + " because they are valid from " + aValidFrom.toString()); continue; }/*from w w w .ja v a 2 s . co m*/ if (aValidTo != null && aValidTo.isBefore(aNow)) { MasterdataLogger.getInstance().info("Ignoring some postal code definitions of " + sCountryName + " because they are valid until " + aValidTo.toString()); continue; } // Read all formats for (final IMicroElement eFormat : ePostalCode.getAllChildElements(ELEMENT_FORMAT)) { final String sFormat = eFormat.getTextContent(); if (StringHelper.hasNoText(sFormat)) throw new IllegalArgumentException( "The country " + sISO + " contains an empty postal code format!"); // Parse into tokens final List<EPostalCodeFormatElement> aElements = _parseFormat(sFormat); if (aElements.isEmpty()) throw new IllegalStateException( "The country " + sISO + " contains an invalid format '" + sFormat + "'"); aCountry.addFormat(new PostalCodeFormat(sISO, aElements)); } // Is exactly one code present? for (final IMicroElement eOneCode : ePostalCode.getAllChildElements(ELEMENT_SPECIFIC)) aCountry.addSpecificPostalCode(eOneCode.getTextContent()); // Is a note present final IMicroElement eNote = ePostalCode.getFirstChildElement(ELEMENT_NOTE); if (eNote != null) aCountry.setNote(eNote.getTextContent()); } if (aCountry.getFormatCount() == 0 && aCountry.getSpecificPostalCodeCount() == 0) throw new IllegalStateException("Country " + sISO + " has no formats defined!"); m_aMgr.addCountry(aCountry); } }
From source file:com.index.IndexServlet.java
/** * Processes requests for both HTTP <code>GET</code> and <code>POST</code> * methods./*from w ww .jav a 2 s . c o m*/ * * @param request servlet request * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html;charset=UTF-8"); if (request.getParameter("startdate") == null && request.getParameter("enddate") == null) { DateTime now = new DateTime(); LocalDate today = now.toLocalDate(); LocalDate tomorrow = today.plusDays(1); IndexData data = new IndexData(today.minusDays(7).toString(), tomorrow.toString(), "leadSession", request.getContextPath()); request.setAttribute("mostlyVisited", data.getMostlyVisited()); request.setAttribute("totalSessionCount", data.getTotalSessionCount()); request.setAttribute("totalAddressCount", data.getTotalAddressCount()); request.setAttribute("companyLinks", data.getCompanyLinks()); request.setAttribute("contacts", data.getContacts()); } if (request.getParameter("startdate") != null && request.getParameter("enddate") != null) { IndexData data = new IndexData(request.getParameter("startdate"), request.getParameter("enddate"), "leadSession", request.getContextPath()); request.setAttribute("mostlyVisited", data.getMostlyVisited()); request.setAttribute("totalSessionCount", data.getTotalSessionCount()); request.setAttribute("totalAddressCount", data.getTotalAddressCount()); request.setAttribute("companyLinks", data.getCompanyLinks()); request.setAttribute("contacts", data.getContacts()); } request.getRequestDispatcher("/index.jsp").forward(request, response); }
From source file:com.miserablemind.api.consumer.tradeking.api.impl.MarketTemplate.java
License:Open Source License
TimeSalesQuote[] getDataPoints(String ticker, TimeSalesInterval interval, Integer countPerPage, Integer offset, LocalDate startDate, LocalDate endDate) { MultiValueMap<String, String> parameters = new LinkedMultiValueMap<>(); parameters.set("symbols", ticker); if (null != interval) { parameters.set("interval", String.valueOf(interval)); if (interval == TimeSalesInterval.TICK && null != countPerPage) { parameters.set("rpp", String.valueOf(countPerPage)); if (null != offset) parameters.set("index", String.valueOf(offset)); }//from w w w . j ava 2 s . c o m } if (null != startDate) parameters.set("startdate", startDate.toString()); if (null != endDate) parameters.set("enddate", endDate.toString()); URI url = this.buildUri(URL_DATA_POINTS, parameters); ResponseEntity<TKTimeSalesQuoteResponse> response = this.getRestTemplate().getForEntity(url, TKTimeSalesQuoteResponse.class); if (null != response.getBody().getError()) throw new ApiException(TradeKingServiceProvider.PROVIDER_ID, response.getBody().getError()); return response.getBody().getQuotes(); }
From source file:com.ning.billing.invoice.generator.DefaultInvoiceGenerator.java
License:Apache License
private void validateTargetDate(final LocalDate targetDate) throws InvoiceApiException { final int maximumNumberOfMonths = config.getNumberOfMonthsInFuture(); if (Months.monthsBetween(clock.getUTCToday(), targetDate).getMonths() > maximumNumberOfMonths) { throw new InvoiceApiException(ErrorCode.INVOICE_TARGET_DATE_TOO_FAR_IN_THE_FUTURE, targetDate.toString()); }/*from w w w .j a v a 2s . c o m*/ }
From source file:com.ning.billing.jaxrs.json.TimeSeriesDataJson.java
License:Apache License
public TimeSeriesDataJson(final TimeSeriesData data) { this(ImmutableList .<String>copyOf(Collections2.transform(data.getDates(), new Function<LocalDate, String>() { @Override//from w ww . ja v a 2 s .com public String apply(@Nullable final LocalDate input) { if (input == null) { return null; } else { return input.toString(); } } })), data.getValues()); }
From source file:com.nitdlibrary.EditViewStudent.java
/** * THIS FUNCTION CALCULATES STUDENT PERFORMCE AND UPDATES FIELDS *//*from www .j av a2 s . co m*/ private void calculateStudentPerformance() throws SQLException { issueResultSet.beforeFirst(); Date returnDate = null, dueDate = null; LocalDate returnDateJoda = null, dueDateJoda = null; int totalIssued = 0, returned = 0, fine = 0, currentIssue = 0; int flag = 0; //incremented when today is > due date and return_date is null. it means that some books are not returned and fine calc is shown wrt today while (issueResultSet.next()) { totalIssued++; if (issueResultSet.getString("return_date") != null) returned++; DateFormat format = new SimpleDateFormat("yyyy-MM-dd", Locale.ENGLISH); try { dueDate = format.parse(issueResultSet.getString("due_date")); /** * IF BOOK HAS NOT BEEN RETURNED AND TODAY>DUEDATE .. FINE TO BE PAID IS SHOWN */ if (issueResultSet.getString("return_date") != null && (issueResultSet.getString("return_date").compareTo("") != 0)) { returnDate = format.parse(issueResultSet.getString("return_date")); } else { String tempDate = format.format(new Date()); returnDate = format.parse(tempDate); if (dueDate.before(returnDate)) // i.e due date before today and book is not returned. flag++; } returnDateJoda = new LocalDate(returnDate); dueDateJoda = new LocalDate(dueDate); } catch (ParseException ex) { Logger.getLogger(EditViewStudent.class.getName()).log(Level.SEVERE, null, ex); } System.out.println( "DUE DATE : " + dueDateJoda.toString() + " RETURN DATE : " + returnDateJoda.toString()); if (dueDate.before(returnDate)) { Days d = Days.daysBetween(dueDateJoda, returnDateJoda); fine += d.getDays(); System.out.println("Calculting fine"); } if (issueResultSet.getString("return_date") == null || (issueResultSet.getString("return_date").compareTo("") == 0)) { currentIssue++; } } /** * setting values in Labels */ issued.setText("Total Books Issued : " + totalIssued); returnedLabel.setText("Total Books Returned : " + returned); if (fine < 0) fine = 0; fineLabel.setText("Total Fine : " + fine); currentLabel.setText("Currently issued book count : " + currentIssue); if (flag != 0) exceedLabel.setText("* " + flag + " books have exceeded due date and are not returned. Assuming they are retuned today, total fine is being shown."); }