List of usage examples for org.joda.time LocalDate toString
public String toString(String pattern)
From source file:org.apache.fineract.portfolio.client.domain.Client.java
License:Apache License
public void activate(final AppUser currentUser, final DateTimeFormatter formatter, final LocalDate activationLocalDate) { if (isActive()) { final String defaultUserMessage = "Cannot activate client. Client is already active."; final ApiParameterError error = ApiParameterError.parameterError("error.msg.clients.already.active", defaultUserMessage, ClientApiConstants.activationDateParamName, activationLocalDate.toString(formatter)); final List<ApiParameterError> dataValidationErrors = new ArrayList<>(); dataValidationErrors.add(error); throw new PlatformApiDataValidationException(dataValidationErrors); }//w ww. j a v a2 s . co m this.activationDate = activationLocalDate.toDate(); this.activatedBy = currentUser; this.officeJoiningDate = this.activationDate; this.status = ClientStatus.ACTIVE.getValue(); validate(); }
From source file:org.apache.fineract.portfolio.loanaccount.rescheduleloan.service.LoanRescheduleRequestWritePlatformServiceImpl.java
License:Apache License
@Override @Transactional/*from w w w . j a v a 2 s .co m*/ public CommandProcessingResult approve(JsonCommand jsonCommand) { try { final Long loanRescheduleRequestId = jsonCommand.entityId(); final LoanRescheduleRequest loanRescheduleRequest = this.loanRescheduleRequestRepository .findOne(loanRescheduleRequestId); if (loanRescheduleRequest == null) { throw new LoanRescheduleRequestNotFoundException(loanRescheduleRequestId); } // validate the request in the JsonCommand object passed as // parameter this.loanRescheduleRequestDataValidator.validateForApproveAction(jsonCommand, loanRescheduleRequest); final AppUser appUser = this.platformSecurityContext.authenticatedUser(); final Map<String, Object> changes = new LinkedHashMap<>(); LocalDate approvedOnDate = jsonCommand.localDateValueOfParameterNamed("approvedOnDate"); final DateTimeFormatter dateTimeFormatter = DateTimeFormat.forPattern(jsonCommand.dateFormat()) .withLocale(jsonCommand.extractLocale()); changes.put("locale", jsonCommand.locale()); changes.put("dateFormat", jsonCommand.dateFormat()); changes.put("approvedOnDate", approvedOnDate.toString(dateTimeFormatter)); changes.put("approvedByUserId", appUser.getId()); if (!changes.isEmpty()) { Loan loan = loanRescheduleRequest.getLoan(); final LoanSummary loanSummary = loan.getSummary(); final boolean isHolidayEnabled = this.configurationDomainService .isRescheduleRepaymentsOnHolidaysEnabled(); final List<Holiday> holidays = this.holidayRepository .findByOfficeIdAndGreaterThanDate(loan.getOfficeId(), loan.getDisbursementDate().toDate()); final WorkingDays workingDays = this.workingDaysRepository.findOne(); final LoanProductMinimumRepaymentScheduleRelatedDetail loanProductRelatedDetail = loan .getLoanRepaymentScheduleDetail(); final MonetaryCurrency currency = loanProductRelatedDetail.getCurrency(); final ApplicationCurrency applicationCurrency = this.applicationCurrencyRepository .findOneWithNotFoundDetection(currency); final InterestMethod interestMethod = loan.getLoanRepaymentScheduleDetail().getInterestMethod(); final RoundingMode roundingMode = MoneyHelper.getRoundingMode(); final MathContext mathContext = new MathContext(8, roundingMode); Collection<LoanRepaymentScheduleHistory> loanRepaymentScheduleHistoryList = this.loanScheduleHistoryWritePlatformService .createLoanScheduleArchive(loan.getRepaymentScheduleInstallments(), loan, loanRescheduleRequest); HolidayDetailDTO holidayDetailDTO = new HolidayDetailDTO(isHolidayEnabled, holidays, workingDays); CalendarInstance restCalendarInstance = null; CalendarInstance compoundingCalendarInstance = null; if (loan.repaymentScheduleDetail().isInterestRecalculationEnabled()) { restCalendarInstance = calendarInstanceRepository.findCalendarInstaneByEntityId( loan.loanInterestRecalculationDetailId(), CalendarEntityType.LOAN_RECALCULATION_REST_DETAIL.getValue()); compoundingCalendarInstance = calendarInstanceRepository.findCalendarInstaneByEntityId( loan.loanInterestRecalculationDetailId(), CalendarEntityType.LOAN_RECALCULATION_COMPOUNDING_DETAIL.getValue()); } final CalendarInstance loanCalendarInstance = calendarInstanceRepository .findCalendarInstaneByEntityId(loan.getId(), CalendarEntityType.LOANS.getValue()); Calendar loanCalendar = null; if (loanCalendarInstance != null) { loanCalendar = loanCalendarInstance.getCalendar(); } FloatingRateDTO floatingRateDTO = constructFloatingRateDTO(loan); LoanRescheduleModel loanRescheduleModel = new DefaultLoanReschedulerFactory().reschedule( mathContext, interestMethod, loanRescheduleRequest, applicationCurrency, holidayDetailDTO, restCalendarInstance, compoundingCalendarInstance, loanCalendar, floatingRateDTO); final Collection<LoanRescheduleModelRepaymentPeriod> periods = loanRescheduleModel.getPeriods(); List<LoanRepaymentScheduleInstallment> repaymentScheduleInstallments = loan .getRepaymentScheduleInstallments(); Collection<LoanCharge> waiveLoanCharges = new ArrayList<>(); for (LoanRescheduleModelRepaymentPeriod period : periods) { if (period.isNew()) { LoanRepaymentScheduleInstallment repaymentScheduleInstallment = new LoanRepaymentScheduleInstallment( loan, period.periodNumber(), period.periodFromDate(), period.periodDueDate(), period.principalDue(), period.interestDue(), BigDecimal.ZERO, BigDecimal.ZERO, false); repaymentScheduleInstallments.add(repaymentScheduleInstallment); } else { for (LoanRepaymentScheduleInstallment repaymentScheduleInstallment : repaymentScheduleInstallments) { if (repaymentScheduleInstallment.getInstallmentNumber() .equals(period.oldPeriodNumber())) { LocalDate periodDueDate = repaymentScheduleInstallment.getDueDate(); Money zeroAmount = Money.of(currency, new BigDecimal(0)); repaymentScheduleInstallment.updateInstallmentNumber(period.periodNumber()); repaymentScheduleInstallment.updateFromDate(period.periodFromDate()); repaymentScheduleInstallment.updateDueDate(period.periodDueDate()); repaymentScheduleInstallment.updatePrincipal(period.principalDue()); repaymentScheduleInstallment.updateInterestCharged(period.interestDue()); if (Money.of(currency, period.principalDue()).isZero() && Money.of(currency, period.interestDue()).isZero() && repaymentScheduleInstallment.isNotFullyPaidOff()) { if (repaymentScheduleInstallment.getPenaltyChargesOutstanding(currency) .isGreaterThan(zeroAmount) || repaymentScheduleInstallment.getFeeChargesOutstanding(currency) .isGreaterThan(zeroAmount)) { waiveLoanCharges.addAll(loan.getLoanCharges(periodDueDate)); } } break; } } } } for (LoanRepaymentScheduleHistory loanRepaymentScheduleHistory : loanRepaymentScheduleHistoryList) { this.loanRepaymentScheduleHistoryRepository.save(loanRepaymentScheduleHistory); } loan.updateRescheduledByUser(appUser); loan.updateRescheduledOnDate(new LocalDate()); // waive all loan charges of zero instalments waiveLoanCharges(loan, waiveLoanCharges); // update the Loan summary loanSummary.updateSummary(currency, loan.getPrincpal(), repaymentScheduleInstallments, new LoanSummaryWrapper(), true, null); // update the total number of schedule repayments loan.updateNumberOfRepayments(periods.size()); // update the loan term frequency (loan term frequency = number // of repayments) loan.updateTermFrequency(periods.size()); // update the status of the request loanRescheduleRequest.approve(appUser, approvedOnDate); // update the derived fields of each loan repayments schedule // instalments for (final LoanRepaymentScheduleInstallment repaymentScheduleInstallment : repaymentScheduleInstallments) { repaymentScheduleInstallment.updateDerivedFields(currency, new LocalDate()); } // updates maturity date loan.updateLoanScheduleDependentDerivedFields(); // update the loan object this.loanRepository.save(loan); } return new CommandProcessingResultBuilder().withCommandId(jsonCommand.commandId()) .withEntityId(loanRescheduleRequestId).withLoanId(loanRescheduleRequest.getLoan().getId()) .with(changes).build(); } catch (final DataIntegrityViolationException dve) { // handle the data integrity violation handleDataIntegrityViolation(dve); // return an empty command processing result object return CommandProcessingResult.empty(); } }
From source file:org.apache.fineract.portfolio.loanaccount.rescheduleloan.service.LoanRescheduleRequestWritePlatformServiceImpl.java
License:Apache License
@Override @Transactional// www.j a v a 2s . com public CommandProcessingResult reject(JsonCommand jsonCommand) { try { final Long loanRescheduleRequestId = jsonCommand.entityId(); final LoanRescheduleRequest loanRescheduleRequest = loanRescheduleRequestRepository .findOne(loanRescheduleRequestId); if (loanRescheduleRequest == null) { throw new LoanRescheduleRequestNotFoundException(loanRescheduleRequestId); } // validate the request in the JsonCommand object passed as // parameter this.loanRescheduleRequestDataValidator.validateForRejectAction(jsonCommand, loanRescheduleRequest); final AppUser appUser = this.platformSecurityContext.authenticatedUser(); final Map<String, Object> changes = new LinkedHashMap<>(); LocalDate rejectedOnDate = jsonCommand.localDateValueOfParameterNamed("rejectedOnDate"); final DateTimeFormatter dateTimeFormatter = DateTimeFormat.forPattern(jsonCommand.dateFormat()) .withLocale(jsonCommand.extractLocale()); changes.put("locale", jsonCommand.locale()); changes.put("dateFormat", jsonCommand.dateFormat()); changes.put("rejectedOnDate", rejectedOnDate.toString(dateTimeFormatter)); changes.put("rejectedByUserId", appUser.getId()); if (!changes.isEmpty()) { loanRescheduleRequest.reject(appUser, rejectedOnDate); } return new CommandProcessingResultBuilder().withCommandId(jsonCommand.commandId()) .withEntityId(loanRescheduleRequestId).withLoanId(loanRescheduleRequest.getLoan().getId()) .with(changes).build(); } catch (final DataIntegrityViolationException dve) { // handle the data integrity violation handleDataIntegrityViolation(dve); // return an empty command processing result object return CommandProcessingResult.empty(); } }
From source file:org.apache.isis.objectstore.jdo.applib.service.settings.ApplicationSettingsServiceJdo.java
License:Apache License
@MemberOrder(sequence = "13") @Override/*w w w. j a v a 2s . c o m*/ public ApplicationSettingJdo newLocalDate(@Named("Key") String key, @Named("Description") @Optional String description, @Named("Value") LocalDate value) { return newSetting(key, description, SettingType.LOCAL_DATE, value.toString(SettingAbstract.DATE_FORMATTER)); }
From source file:org.apache.isis.objectstore.jdo.applib.service.settings.SettingAbstractJdo.java
License:Apache License
@MemberOrder(name = "ValueAsLocalDate", sequence = "1") @Named("Update")// w w w . ja v a 2 s.com public SettingAbstractJdo updateAsLocalDate(@Named("Value") LocalDate value) { setValueRaw(value.toString(DATE_FORMATTER)); return this; }
From source file:org.apache.isis.objectstore.jdo.applib.service.settings.UserSettingsServiceJdo.java
License:Apache License
@MemberOrder(sequence = "13") public UserSettingJdo newLocalDate(@Named("User") String user, @Named("Key") String key, @Named("Description") @Optional String description, @Named("Value") LocalDate value) { return newSetting(user, key, description, SettingType.LOCAL_DATE, value.toString(SettingAbstract.DATE_FORMATTER)); }
From source file:org.archfirst.common.datetime.DateTimeUtil.java
License:Apache License
public static final String toString(LocalDate date) { DateTimeFormatter fmt = DateTimeFormat.forPattern(DateTimeUtil.DATE_PATTERN); return date.toString(fmt); }
From source file:org.biokoframework.system.repository.sql.translator.annotation.impl.LocalDateTranslator.java
License:Open Source License
@Override public void insertIntoStatement(String fieldName, Object fieldValue, Field fieldAnnotation, PreparedStatement statement, int sqlIndex) throws SQLException { if (fieldValue == null) { statement.setObject(sqlIndex, null); } else {/*from w w w. java 2s . c om*/ LocalDate timestamp = LocalDate.parse((String) fieldValue); statement.setString(sqlIndex, timestamp.toString(DateTimeFormat.forPattern(MYSQL_DATE))); } }
From source file:org.egov.lcms.transactions.service.LegalCommonReportService.java
License:Open Source License
private BoolQueryBuilder getFilterQuery(final LegalCommonReportResult searchRequest, final String reportType) throws ParseException { final SimpleDateFormat formatter = new SimpleDateFormat(LcmsConstants.DATE_FORMAT); final SimpleDateFormat newFormat = new SimpleDateFormat(ApplicationConstant.ES_DATE_FORMAT); final Map<String, Integer> monthValuesMapnumber = LegalCaseUtil.getAllMonthsInNumber(); BoolQueryBuilder boolQuery = QueryBuilders.boolQuery(); boolQuery.filter(QueryBuilders.termQuery("cityName", ApplicationThreadLocals.getCityName())); if (StringUtils.isNotBlank(searchRequest.getAggregatedByValue())) { if (searchRequest.getAggregatedBy().equals(LcmsConstants.COURTNAME)) boolQuery.filter(QueryBuilders.matchQuery(COURTNAME, searchRequest.getAggregatedByValue())); if (searchRequest.getAggregatedBy().equals(LcmsConstants.PETITIONTYPE)) boolQuery.filter(QueryBuilders.matchQuery(PETITIONTYPE, searchRequest.getAggregatedByValue())); else if (searchRequest.getAggregatedBy().equals(LcmsConstants.CASECATEGORY)) boolQuery.filter(QueryBuilders.matchQuery(CASETYPE, searchRequest.getAggregatedByValue())); else if (searchRequest.getAggregatedBy().equals(LcmsConstants.CASESTATUS)) boolQuery.filter(QueryBuilders.matchQuery(CASESTATUS, searchRequest.getAggregatedByValue())); else if (searchRequest.getAggregatedBy().equals(LcmsConstants.COURTTYPE)) boolQuery.filter(QueryBuilders.matchQuery(COURTTYPE, searchRequest.getAggregatedByValue())); else if (searchRequest.getAggregatedBy().equals(LcmsConstants.OFFICERINCHRGE)) boolQuery.filter(QueryBuilders.matchQuery(OFFICERINCHRGE, searchRequest.getAggregatedByValue().split("@")[0])); else if (searchRequest.getAggregatedBy().equals(LcmsConstants.STANDINGCOUNSEL)) boolQuery.filter(QueryBuilders.matchQuery(STANDINGCOUNSEL, searchRequest.getAggregatedByValue())); else if (searchRequest.getAggregatedBy().equals(LcmsConstants.JUDGEMENTOUTCOME)) boolQuery.filter(QueryBuilders.matchQuery(JUDGEMENTOUTCOME, searchRequest.getAggregatedByValue())); }/* ww w . j a v a2 s. c o m*/ if (StringUtils.isNotBlank(searchRequest.getMonth()) && StringUtils.isNotBlank(searchRequest.getYear())) { final Integer monthName = monthValuesMapnumber.get(searchRequest.getMonth()); // Prepare the start date based on the month number and year final String monthYearStartDateStr = searchRequest.getYear().concat("-").concat(monthName.toString()) .concat("-").concat("01"); final LocalDate monthYearStDate = new LocalDate(monthYearStartDateStr); // Fetch the start date of the 1st week of the month and the last day of the month if (MONTH.equalsIgnoreCase(searchRequest.getPeriod())) { final LocalDate weekStart = monthYearStDate.dayOfWeek().withMinimumValue(); final LocalDate endOfMonth = monthYearStDate.dayOfMonth().withMaximumValue(); final String startDate = weekStart.toString(LcmsConstants.DATE_FORMAT); final String endDate = endOfMonth.toString(LcmsConstants.DATE_FORMAT); boolQuery = boolQuery.filter( QueryBuilders.rangeQuery(CASE_DATE).gte(newFormat.format(formatter.parse(startDate))) .lte(new DateTime(newFormat.format(formatter.parse(endDate))))); } if (YEAR.equalsIgnoreCase(searchRequest.getPeriod())) { final LocalDate monthStart = monthYearStDate.dayOfMonth().withMinimumValue(); final LocalDate endOfYear = monthYearStDate.dayOfYear().withMaximumValue(); final String startDate = monthStart.toString(LcmsConstants.DATE_FORMAT); final String endDate = endOfYear.toString(LcmsConstants.DATE_FORMAT); boolQuery = boolQuery.filter( QueryBuilders.rangeQuery(CASE_DATE).gte(newFormat.format(formatter.parse(startDate))) .lte(new DateTime(newFormat.format(formatter.parse(endDate))))); } } if (reportType != null) { if (reportType.equals(LcmsConstants.DUEPWRREPORT)) boolQuery.mustNot(QueryBuilders.existsQuery("pwrDueDate")); else if (reportType.equals(LcmsConstants.DUECAREPORT)) boolQuery.must(QueryBuilders.existsQuery("caDueDate")); else if (reportType.equals(LcmsConstants.DUEJUDGEMENTIMPLPREPORT)) boolQuery.mustNot(QueryBuilders.matchQuery("status", LcmsConstants.LEGALCASE_STATUS_CLOSED_DESC)); if (reportType.equals(LcmsConstants.DUEJUDGEMENTIMPLPREPORT) && StringUtils.isNotBlank(searchRequest.getCaseFromDate())) boolQuery = boolQuery.filter(QueryBuilders.rangeQuery("judgmentImplDate") .gte(newFormat.format(formatter.parse(searchRequest.getCaseFromDate()))) .lte(new DateTime(newFormat.format(formatter.parse(searchRequest.getCaseToDate()))))); if (reportType.equals(LcmsConstants.DUEEMPLOYEEHEARINGREPORT)) { final List<String> statusCodeList = new ArrayList<>(); statusCodeList.add(LcmsConstants.LEGALCASE_STATUS_HEARING_DESC); statusCodeList.add(LcmsConstants.LEGALCASE_INTERIMSTAY_STATUS_DESC); boolQuery.must(QueryBuilders.termsQuery(CASESTATUS, statusCodeList)); if (searchRequest.getLcNumber() != null) boolQuery = boolQuery.filter(QueryBuilders.matchQuery("lcNumber", searchRequest.getLcNumber())); if (StringUtils.isNotBlank(searchRequest.getCaseFromDate())) boolQuery = boolQuery.filter(QueryBuilders.rangeQuery(CASE_DATE) .gte(newFormat.format(formatter.parse(searchRequest.getCaseFromDate()))) .lte(new DateTime(newFormat.format(formatter.parse(searchRequest.getCaseToDate()))))); } } else if (StringUtils.isNotBlank(searchRequest.getCaseFromDate())) boolQuery = boolQuery.filter(QueryBuilders.rangeQuery(CASE_DATE) .gte(newFormat.format(formatter.parse(searchRequest.getCaseFromDate()))) .lte(new DateTime(newFormat.format(formatter.parse(searchRequest.getCaseToDate()))))); if (StringUtils.isNotBlank(searchRequest.getOfficerIncharge())) boolQuery = boolQuery.filter( QueryBuilders.termQuery(OFFICERINCHRGE, searchRequest.getOfficerIncharge().split("@")[0])); if (StringUtils.isNotBlank(searchRequest.getCaseCategory())) boolQuery = boolQuery.filter(QueryBuilders.termQuery(CASETYPE, searchRequest.getCaseCategory())); if (StringUtils.isNotBlank(searchRequest.getCourtName())) boolQuery = boolQuery.filter(QueryBuilders.termQuery(COURTNAME, searchRequest.getCourtName())); if (StringUtils.isNotBlank(searchRequest.getCaseStatus())) boolQuery = boolQuery.filter(QueryBuilders.termQuery(CASESTATUS, searchRequest.getCaseStatus())); if (StringUtils.isNotBlank(searchRequest.getCourtType())) boolQuery = boolQuery.filter(QueryBuilders.termQuery(COURTTYPE, searchRequest.getCourtType())); if (StringUtils.isNotBlank(searchRequest.getPetitionType())) boolQuery = boolQuery.filter(QueryBuilders.termQuery(PETITIONTYPE, searchRequest.getPetitionType())); if (StringUtils.isNotBlank(searchRequest.getJudgmentType())) boolQuery = boolQuery .filter(QueryBuilders.termQuery(JUDGEMENTOUTCOME, searchRequest.getJudgmentType())); if (StringUtils.isNotBlank(searchRequest.getStandingCounsel())) boolQuery = boolQuery .filter(QueryBuilders.termQuery("advocateName", searchRequest.getStandingCounsel())); if (StringUtils.isNotBlank(searchRequest.getReportStatus())) boolQuery = boolQuery.filter(QueryBuilders.termQuery("subStatus", searchRequest.getReportStatus())); return boolQuery; }
From source file:org.egov.ptis.web.controller.dashboard.CMDashboardController.java
License:Open Source License
/** * Provides citywise DCB details across all ULBs for MIS Reports * @return response JSON/*from ww w . jav a2 s . c o m*/ * @throws IOException */ @RequestMapping(value = "/citywisedcb", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseBody public MISDCBDetails getDCBDetailsForMIS(CollectionDetailsRequest collectionDetailsRequest) { MISDCBDetails misDCBDetails = new MISDCBDetails(); List<WeeklyDCB> weekwiseDCBDetails; List<MonthlyDCB> monthwiseDCBDetails; if (StringUtils.isBlank(collectionDetailsRequest.getIntervalType())) misDCBDetails.setDcbDetails(propTaxDashboardService.getDCBDetails(collectionDetailsRequest)); else { String startDate; String endDate; if (WEEK.equalsIgnoreCase(collectionDetailsRequest.getIntervalType())) { String monthStartDateStr = collectionDetailsRequest.getYear().concat("-") .concat(collectionDetailsRequest.getMonth()).concat("-").concat("01"); LocalDate monthStDate = new LocalDate(monthStartDateStr); // Fetch the start date of the 1st week of the month and the last day of the month LocalDate weekStart = monthStDate.dayOfWeek().withMinimumValue(); LocalDate endOfMonth = monthStDate.dayOfMonth().withMaximumValue(); startDate = weekStart.toString(PropertyTaxConstants.DATE_FORMAT_YYYYMMDD); endDate = endOfMonth.toString(PropertyTaxConstants.DATE_FORMAT_YYYYMMDD); collectionDetailsRequest.setFromDate(startDate); collectionDetailsRequest.setToDate(endDate); } } if (WEEK.equalsIgnoreCase(collectionDetailsRequest.getIntervalType())) { weekwiseDCBDetails = propTaxDashboardService.getWeekwiseDCBDetails(collectionDetailsRequest, collectionDetailsRequest.getIntervalType()); misDCBDetails.setWeeklyDCBDetails(weekwiseDCBDetails); } else if (MONTH.equalsIgnoreCase(collectionDetailsRequest.getIntervalType())) { monthwiseDCBDetails = propTaxDashboardService.getMonthwiseDCBDetails(collectionDetailsRequest, collectionDetailsRequest.getIntervalType()); misDCBDetails.setMonthlyDCBDetails(monthwiseDCBDetails); } return misDCBDetails; }