List of usage examples for org.joda.time LocalDate now
public static LocalDate now()
ISOChronology
in the default time zone. From source file:org.mifosplatform.portfolio.loanaccount.service.LoanWritePlatformServiceJpaRepositoryImpl.java
License:Mozilla Public License
private boolean addCharge(final Loan loan, final Charge chargeDefinition, final LoanCharge loanCharge) { AppUser currentUser = getAppUserIfPresent(); if (!loan.hasCurrencyCodeOf(chargeDefinition.getCurrencyCode())) { final String errorMessage = "Charge and Loan must have the same currency."; throw new InvalidCurrencyException("loanCharge", "attach.to.loan", errorMessage); }//w ww . j av a2 s . c o m if (loanCharge.getChargePaymentMode().isPaymentModeAccountTransfer()) { final PortfolioAccountData portfolioAccountData = this.accountAssociationsReadPlatformService .retriveLoanLinkedAssociation(loan.getId()); if (portfolioAccountData == null) { final String errorMessage = loanCharge.name() + "Charge requires linked savings account for payment"; throw new LinkedAccountRequiredException("loanCharge.add", errorMessage, loanCharge.name()); } } this.loanChargeRepository.save(loanCharge); loan.addLoanCharge(loanCharge); /** * we want to apply charge transactions only for those loans charges * that are applied when a loan is active and the loan product uses * Upfront Accruals **/ if (loan.status().isActive() && loan.isNoneOrCashOrUpfrontAccrualAccountingEnabledOnLoanProduct()) { final LoanTransaction applyLoanChargeTransaction = loan.handleChargeAppliedTransaction(loanCharge, null, currentUser); this.loanTransactionRepository.save(applyLoanChargeTransaction); } boolean isAppliedOnBackDate = false; if (loanCharge.getDueLocalDate() == null || LocalDate.now().isAfter(loanCharge.getDueLocalDate())) { isAppliedOnBackDate = true; } return isAppliedOnBackDate; }
From source file:org.mifosplatform.portfolio.pgs.transactionrecord.domain.TransactionRecordAssembler.java
License:Mozilla Public License
public TransactionRecord assembleFromJson(final JsonCommand command) { final JsonElement element = command.parsedJson(); Long serviceAccountId = null; String description = null;/*w w w . j ava 2s . com*/ LocalDate localdate = null; Date date = null; Integer type = null; Double amount = null; if (command.getServiceAccountId() != null) { serviceAccountId = command.getServiceAccountId(); } final ServiceAccount serviceAccount = this.serviceAccountRepository.findOne(serviceAccountId); if (this.fromApiJsonHelper.parameterExists(TransactionRecordApiConstants.descriptionParamName, element)) { description = this.fromApiJsonHelper .extractStringNamed(TransactionRecordApiConstants.descriptionParamName, element); } //TODO figure out how to work with dates if (this.fromApiJsonHelper.parameterExists(TransactionRecordApiConstants.dateParamName, element)) { localdate = this.fromApiJsonHelper.extractLocalDateNamed(TransactionRecordApiConstants.dateParamName, element); if (localdate != null) { date = localdate.toDate(); } else { date = LocalDate.now().toDate(); } } if (this.fromApiJsonHelper.parameterExists(TransactionRecordApiConstants.typeParamName, element)) { type = this.fromApiJsonHelper.extractIntegerNamed(TransactionRecordApiConstants.typeParamName, element, Locale.getDefault()); } if (this.fromApiJsonHelper.parameterExists(TransactionRecordApiConstants.amountParamName, element)) { amount = this.fromApiJsonHelper.extractDoubleNamed(TransactionRecordApiConstants.amountParamName, element); } return TransactionRecord.createNew(serviceAccount, description, date, type, amount); }
From source file:org.mifosplatform.portfolio.pgs.usagerecord.domain.UsageRecordAssembler.java
License:Mozilla Public License
public UsageRecord assembleFromJson(final JsonCommand command) { final JsonElement element = command.parsedJson(); long serviceAccountId = 0; LocalDate localdate = null;/*from w w w .j a va2 s .c o m*/ Date date = null; double noOfUnits = 0.0; Integer metricType = null; Date startDate = null; Date endDate = null; if (command.getServiceAccountId() != null) { serviceAccountId = command.getServiceAccountId(); } final ServiceAccount serviceAccount = this.serviceAccountRepository.findOne(serviceAccountId); if (this.fromApiJsonHelper.parameterExists(UsageRecordApiConstants.dateParamName, element)) { localdate = this.fromApiJsonHelper.extractLocalDateNamed(UsageRecordApiConstants.dateParamName, element); if (localdate != null) { date = localdate.toDate(); } else { date = LocalDate.now().toDate(); } } if (this.fromApiJsonHelper.parameterExists(UsageRecordApiConstants.noOfUnitsParamName, element)) { noOfUnits = this.fromApiJsonHelper.extractDoubleNamed(UsageRecordApiConstants.noOfUnitsParamName, element); } if (this.fromApiJsonHelper.parameterExists(UsageRecordApiConstants.metricTypeParamName, element)) { metricType = this.fromApiJsonHelper.extractIntegerNamed(UsageRecordApiConstants.metricTypeParamName, element, Locale.getDefault()); } if (this.fromApiJsonHelper.parameterExists(UsageRecordApiConstants.startDateParamName, element)) { localdate = this.fromApiJsonHelper.extractLocalDateNamed(UsageRecordApiConstants.startDateParamName, element); if (localdate != null) { startDate = localdate.toDate(); } else { startDate = LocalDate.now().toDate(); } } if (this.fromApiJsonHelper.parameterExists(UsageRecordApiConstants.endDateParamName, element)) { localdate = this.fromApiJsonHelper.extractLocalDateNamed(UsageRecordApiConstants.endDateParamName, element); if (localdate != null) { endDate = localdate.toDate(); } else { endDate = LocalDate.now().toDate(); } } return UsageRecord.createNew(serviceAccount, date, metricType, noOfUnits, startDate, endDate); }
From source file:org.mpardalos.homework_plus.TaskAdd.java
License:Open Source License
@SuppressWarnings("unused") public void onDueDateClicked(View view) { DatePickerFragment dateInput = new DatePickerFragment(); LocalDate previousInput = (LocalDate) view.getTag(R.id.due_date); if (!(previousInput == null)) { Bundle args = new Bundle(); args.putSerializable("previousInput", previousInput); dateInput.setArguments(args);/*from ww w . ja v a 2 s . c o m*/ } else { Bundle args = new Bundle(); args.putSerializable("previousInput", LocalDate.now()); dateInput.setArguments(args); } dateInput.show(getFragmentManager(), "dueDateInput"); }
From source file:org.onebusaway.admin.service.bundle.task.FixedRouteDataValidationTask.java
License:Apache License
private LocalDate getFirstDay(int dayOfWeek) { LocalDate today = LocalDate.now(); int old = today.getDayOfWeek(); if (dayOfWeek < old) { dayOfWeek += 7;//from www .j a va 2s.c o m } return today.plusDays(dayOfWeek - old); }
From source file:org.openlmis.web.controller.DeliveryZoneProgramScheduleController.java
License:Open Source License
@RequestMapping(value = "deliveryZones/{zoneId}/programs/{programId}/periods", method = GET, headers = ACCEPT_JSON) public ResponseEntity<OpenLmisResponse> getPeriodsForProgramInDeliveryZone(HttpServletRequest request, @PathVariable long zoneId, @PathVariable final long programId) { if (permissionService.hasPermissionOnZone(loggedInUserId(request), zoneId)) { Date elevenDaysFromNow = LocalDate.now().plusDays(11).toDate(); List<ProcessingPeriod> periodsForDeliveryZoneAndProgram = scheduleService .getPeriodsForDeliveryZoneAndProgram(zoneId, programId, elevenDaysFromNow); final List<Long> syncedPeriods = distributionService.getSyncedPeriodsForDeliveryZoneAndProgram(zoneId, programId);/* ww w . j a va2s . c om*/ Collection unsyncedPeriodsForZoneAndProgram = CollectionUtils.select(periodsForDeliveryZoneAndProgram, new Predicate() { @Override public boolean evaluate(Object o) { ProcessingPeriod period = (ProcessingPeriod) o; return !syncedPeriods.contains(period.getId()); } }); return OpenLmisResponse.response(PERIODS, unsyncedPeriodsForZoneAndProgram); } else { return OpenLmisResponse.error(FORBIDDEN_EXCEPTION, HttpStatus.UNAUTHORIZED); } }
From source file:org.openmastery.storyweb.resources.MetricsResource.java
License:Open Source License
/** * Generate a chart with explodable (drill-downable) graphpoints, from task, to journey, to discovery cycle, to execution cycle * @param startDate inclusive beginning/*from w w w . ja va2 s . c o m*/ * @param endDate exclusive end * @return SPCChart */ @GET @Path(ResourcePaths.METRICS_SPC_PATH) public SPCChart generateSPCChart(@QueryParam("startDate") String startDate, @QueryParam("endDate") String endDate) { System.out.println("generateSPCChart [" + startDate + " : " + endDate + "]"); LocalDate jodaStartDate; LocalDate jodaEndDate; if (startDate != null && endDate != null) { DateTimeFormatter formatter = DateTimeFormat.forPattern("yyyyMMdd"); jodaStartDate = formatter.parseLocalDate(startDate); jodaEndDate = formatter.parseLocalDate(endDate); } else { jodaStartDate = LocalDate.now().minusDays(7); jodaEndDate = LocalDate.now(); } return metricsService.generateSPCChart(jodaStartDate, jodaEndDate); }
From source file:org.openmrs.module.referencedemodata.ReferenceDemoDataActivator.java
License:Open Source License
private Date randomBirthdate() { LocalDate now = LocalDate.now(); LocalDate joda = new LocalDate(randomBetween(now.getYear() - MAX_AGE, now.getYear() - MIN_AGE), randomBetween(1, 12), randomBetween(1, 28)); return joda.toDate(); }
From source file:org.opentestsystem.delivery.testreg.rest.ProctorPackageController.java
License:Open Source License
/** * Exports Assessments./*from ww w . j av a2 s .c o m*/ * * @param request * HttpServlet request * @param response * HttpServlet response * @return SearchResponse containing assessments */ @RequestMapping(value = "/proctorassessments", method = RequestMethod.GET, produces = MediaType.APPLICATION_XML_VALUE) @Secured({ "ROLE_Entity Read" }) @ResponseBody public String exportProctorPackage(final HttpServletRequest request, final HttpServletResponse response, @RequestParam(value = "entityLevel", required = true) final String entityLevel, @RequestParam(value = "entityName", required = true) final String entityName, @RequestParam(value = "stateAbbreviation", required = false) final String stateAbbreviation, @RequestParam(value = "date", required = false) @DateTimeFormat(pattern = "yyyy-MM-dd") final Date date) { DateTime localDate; if (date == null) { localDate = LocalDate.now().toDateTimeAtStartOfDay(); } else { localDate = new LocalDate(date.getTime()).toDateTimeAtStartOfDay(); } return proctorassessmentService.exportProctorPackage(entityLevel, entityName, stateAbbreviation, localDate); }
From source file:org.projectbuendia.client.filter.db.patient.AgeFilter.java
License:Apache License
@Override public String[] getSelectionArgs(CharSequence constraint) { LocalDate earliestBirthdate = LocalDate.now().minusYears(mYears); return new String[] { earliestBirthdate.toString() }; }