Example usage for org.joda.time LocalDate fromDateFields

List of usage examples for org.joda.time LocalDate fromDateFields

Introduction

In this page you can find the example usage for org.joda.time LocalDate fromDateFields.

Prototype

@SuppressWarnings("deprecation")
public static LocalDate fromDateFields(Date date) 

Source Link

Document

Constructs a LocalDate from a java.util.Date using exactly the same field values.

Usage

From source file:com.gst.portfolio.account.domain.AccountTransferStandingInstruction.java

License:Apache License

private void validateDependencies(final DataValidatorBuilder baseDataValidator) {

    if (this.validTill != null && this.validFrom != null) {
        baseDataValidator.reset().parameter(validTillParamName).value(LocalDate.fromDateFields(this.validTill))
                .validateDateAfter(LocalDate.fromDateFields(this.validFrom));
    }/*from  w  ww  . j  a va 2 s .c  o  m*/

    if (AccountTransferRecurrenceType.fromInt(recurrenceType).isPeriodicRecurrence()) {
        baseDataValidator.reset().parameter(recurrenceFrequencyParamName).value(this.recurrenceFrequency)
                .notNull();
        baseDataValidator.reset().parameter(recurrenceIntervalParamName).value(this.recurrenceInterval)
                .notNull();
        if (this.recurrenceFrequency != null) {
            PeriodFrequencyType frequencyType = PeriodFrequencyType.fromInt(this.recurrenceFrequency);
            if (frequencyType.isMonthly()) {
                baseDataValidator.reset().parameter(recurrenceOnMonthDayParamName).value(this.recurrenceOnDay)
                        .notNull();
            } else if (frequencyType.isYearly()) {
                baseDataValidator.reset().parameter(recurrenceOnMonthDayParamName).value(this.recurrenceOnDay)
                        .notNull();
                baseDataValidator.reset().parameter(recurrenceOnMonthDayParamName).value(this.recurrenceOnMonth)
                        .notNull();
            }
        }
    }

    if (this.accountTransferDetails.toSavingsAccount() != null) {
        baseDataValidator.reset().parameter(instructionTypeParamName).value(this.instructionType).notNull()
                .inMinMaxRange(1, 1);
        baseDataValidator.reset().parameter(recurrenceTypeParamName).value(this.recurrenceType).notNull()
                .inMinMaxRange(1, 1);
    }

    if (StandingInstructionType.fromInt(this.instructionType).isFixedAmoutTransfer()) {
        baseDataValidator.reset().parameter(amountParamName).value(this.amount).notNull();
    }

    String errorCode = null;
    if (this.accountTransferDetails.transferType().isAccountTransfer()
            && (this.accountTransferDetails.fromSavingsAccount() == null
                    || this.accountTransferDetails.toSavingsAccount() == null)) {
        errorCode = "not.account.transfer";
    } else if (this.accountTransferDetails.transferType().isLoanRepayment()
            && (this.accountTransferDetails.fromSavingsAccount() == null
                    || this.accountTransferDetails.toLoanAccount() == null)) {
        errorCode = "not.loan.repayment";
    }
    if (errorCode != null) {
        baseDataValidator.reset().parameter(transferTypeParamName).failWithCode(errorCode);
    }

}

From source file:com.gst.portfolio.calendar.domain.Calendar.java

License:Apache License

public LocalDate getStartDateLocalDate() {
    LocalDate startDateLocalDate = null;
    if (this.startDate != null) {
        startDateLocalDate = LocalDate.fromDateFields(this.startDate);
    }/*  w  w  w  .  j  a va 2  s .  c o  m*/
    return startDateLocalDate;
}

From source file:com.gst.portfolio.calendar.domain.Calendar.java

License:Apache License

public LocalDate getEndDateLocalDate() {
    LocalDate endDateLocalDate = null;
    if (this.endDate != null) {
        endDateLocalDate = LocalDate.fromDateFields(this.endDate);
    }//from   ww  w .j a  v  a  2  s.com
    return endDateLocalDate;
}

From source file:com.gst.portfolio.client.domain.Client.java

License:Apache License

public LocalDate getActivationLocalDate() {
    LocalDate activationLocalDate = null;
    if (this.activationDate != null) {
        activationLocalDate = LocalDate.fromDateFields(this.activationDate);
    }/*from  ww  w  .ja  va 2  s  .  com*/
    return activationLocalDate;
}

From source file:com.gst.portfolio.client.domain.Client.java

License:Apache License

public LocalDate getOfficeJoiningLocalDate() {
    LocalDate officeJoiningLocalDate = null;
    if (this.officeJoiningDate != null) {
        officeJoiningLocalDate = LocalDate.fromDateFields(this.officeJoiningDate);
    }/*from w w w. j a v  a  2 s  . com*/
    return officeJoiningLocalDate;
}

From source file:com.gst.portfolio.client.domain.Client.java

License:Apache License

public LocalDate dateOfBirthLocalDate() {
    LocalDate dateOfBirth = null;
    if (this.dateOfBirth != null) {
        dateOfBirth = LocalDate.fromDateFields(this.dateOfBirth);
    }//from  w w w. j  av a 2  s .co m
    return dateOfBirth;
}

From source file:com.gst.portfolio.client.domain.ClientNonPerson.java

License:Apache License

public LocalDate getIncorpValidityTillLocalDate() {
    LocalDate incorpValidityTillLocalDate = null;
    if (this.incorpValidityTill != null) {
        incorpValidityTillLocalDate = LocalDate.fromDateFields(this.incorpValidityTill);
    }//from ww w .  java2 s  .c o  m
    return incorpValidityTillLocalDate;
}

From source file:com.gst.portfolio.floatingrates.domain.FloatingRate.java

License:Apache License

private void updateRatePeriods(final List<FloatingRatePeriod> newRatePeriods, final AppUser appUser) {
    final LocalDate today = DateUtils.getLocalDateOfTenant();
    if (this.floatingRatePeriods != null) {
        for (FloatingRatePeriod ratePeriod : this.floatingRatePeriods) {
            LocalDate fromDate = LocalDate.fromDateFields(ratePeriod.getFromDate());
            if (fromDate.isAfter(today)) {
                ratePeriod.setActive(false);
                ratePeriod.setModifiedBy(appUser);
                ratePeriod.setModifiedOn(today.toDate());
            }// w  ww  . j ava  2 s.  c om
        }
    }
    for (FloatingRatePeriod newRatePeriod : newRatePeriods) {
        newRatePeriod.updateFloatingRate(this);
        this.floatingRatePeriods.add(newRatePeriod);
    }
}

From source file:com.gst.portfolio.interestratechart.incentive.ClientAttributeIncentiveCalculation.java

License:Apache License

@Override
public BigDecimal calculateIncentive(IncentiveDTO incentiveDTO) {
    final Client client = incentiveDTO.client();
    BigDecimal interest = incentiveDTO.interest();
    final InterestIncentivesFields incentivesFields = incentiveDTO.incentives();
    boolean applyIncentive = false;
    switch (incentivesFields.attributeName()) {
    case GENDER:/*from  w  w w.j  av a  2  s  . co m*/
        if (client.genderId() != null) {
            applyIncentive = applyIncentive(incentivesFields.conditionType(),
                    Long.valueOf(incentivesFields.attributeValue()), client.genderId());
        }
        break;
    case AGE:
        if (client.dateOfBirth() != null) {
            final LocalDate dobLacalDate = LocalDate.fromDateFields(client.dateOfBirth());
            final int age = Years.yearsBetween(dobLacalDate, LocalDate.now()).getYears();
            applyIncentive = applyIncentive(incentivesFields.conditionType(),
                    Long.valueOf(incentivesFields.attributeValue()), Long.valueOf(age));
        }
        break;
    case CLIENT_TYPE:
        if (client.clientTypeId() != null) {
            applyIncentive = applyIncentive(incentivesFields.conditionType(),
                    Long.valueOf(incentivesFields.attributeValue()), client.clientTypeId());
        }
        break;
    case CLIENT_CLASSIFICATION:
        if (client.clientClassificationId() != null) {
            applyIncentive = applyIncentive(incentivesFields.conditionType(),
                    Long.valueOf(incentivesFields.attributeValue()), client.clientClassificationId());
        }
        break;

    default:
        break;

    }
    if (applyIncentive) {
        switch (incentivesFields.incentiveType()) {
        case FIXED:
            interest = incentivesFields.amount();
            break;
        case INCENTIVE:
            interest = interest.add(incentivesFields.amount());
            break;
        default:
            break;

        }
    }

    return interest;
}

From source file:com.gst.portfolio.loanaccount.api.LoanTransactionsApiResource.java

License:Apache License

@GET
@Path("template")
@Consumes({ MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_JSON })
public String retrieveTransactionTemplate(@PathParam("loanId") final Long loanId,
        @QueryParam("command") final String commandParam, @Context final UriInfo uriInfo,
        @QueryParam("dateFormat") final String dateFormat,
        @QueryParam("transactionDate") final DateParam transactionDateParam,
        @QueryParam("locale") final String locale) {

    this.context.authenticatedUser().validateHasReadPermission(this.resourceNameForPermissions);

    LoanTransactionData transactionData = null;
    if (is(commandParam, "repayment")) {
        transactionData = this.loanReadPlatformService.retrieveLoanTransactionTemplate(loanId);
    } else if (is(commandParam, "waiveinterest")) {
        transactionData = this.loanReadPlatformService.retrieveWaiveInterestDetails(loanId);
    } else if (is(commandParam, "writeoff")) {
        transactionData = this.loanReadPlatformService.retrieveLoanWriteoffTemplate(loanId);
    } else if (is(commandParam, "close-rescheduled")) {
        transactionData = this.loanReadPlatformService.retrieveNewClosureDetails();
    } else if (is(commandParam, "close")) {
        transactionData = this.loanReadPlatformService.retrieveNewClosureDetails();
    } else if (is(commandParam, "disburse")) {
        transactionData = this.loanReadPlatformService.retrieveDisbursalTemplate(loanId, true);
    } else if (is(commandParam, "disburseToSavings")) {
        transactionData = this.loanReadPlatformService.retrieveDisbursalTemplate(loanId, false);
    } else if (is(commandParam, "recoverypayment")) {
        transactionData = this.loanReadPlatformService.retrieveRecoveryPaymentTemplate(loanId);
    } else if (is(commandParam, "prepayLoan")) {
        LocalDate transactionDate = null;
        if (transactionDateParam == null) {
            transactionDate = DateUtils.getLocalDateOfTenant();
        } else {/*from  www  .ja  va 2  s.  c  om*/
            transactionDate = LocalDate
                    .fromDateFields(transactionDateParam.getDate("transactionDate", dateFormat, locale));
        }
        transactionData = this.loanReadPlatformService.retrieveLoanPrePaymentTemplate(loanId, transactionDate);
    } else if (is(commandParam, "refundbycash")) {
        transactionData = this.loanReadPlatformService.retrieveRefundByCashTemplate(loanId);
    } else if (is(commandParam, "refundbytransfer")) {
        transactionData = this.loanReadPlatformService.retrieveDisbursalTemplate(loanId, true);
    } else if (is(commandParam, "foreclosure")) {
        LocalDate transactionDate = null;
        if (transactionDateParam == null) {
            transactionDate = DateUtils.getLocalDateOfTenant();
        } else {
            transactionDate = LocalDate
                    .fromDateFields(transactionDateParam.getDate("transactionDate", dateFormat, locale));
        }
        transactionData = this.loanReadPlatformService.retrieveLoanForeclosureTemplate(loanId, transactionDate);
    } else {
        throw new UnrecognizedQueryParamException("command", commandParam);
    }

    final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper
            .process(uriInfo.getQueryParameters());
    return this.toApiJsonSerializer.serialize(settings, transactionData, this.RESPONSE_DATA_PARAMETERS);
}