Example usage for org.joda.time LocalDate toDateTimeAtStartOfDay

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

Introduction

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

Prototype

public DateTime toDateTimeAtStartOfDay() 

Source Link

Document

Converts this LocalDate to a full datetime at the earliest valid time for the date using the default time zone.

Usage

From source file:com.gst.portfolio.loanaccount.domain.LoanTransaction.java

License:Apache License

private LoanTransaction(final Loan loan, final Office office, final LoanTransactionType type,
        final PaymentDetail paymentDetail, final BigDecimal amount, final LocalDate date,
        final String externalId, final LocalDateTime createdDate, final AppUser appUser) {
    this.loan = loan;
    this.typeOf = type.getValue();
    this.paymentDetail = paymentDetail;
    this.amount = amount;
    this.dateOf = date.toDateTimeAtStartOfDay().toDate();
    this.externalId = externalId;
    this.office = office;
    this.submittedOnDate = DateUtils.getDateOfTenant();
    this.createdDate = createdDate.toDate();
    this.appUser = appUser;
}

From source file:com.gst.portfolio.loanproduct.domain.LoanProduct.java

License:Apache License

public LoanProduct(final Fund fund, final LoanTransactionProcessingStrategy transactionProcessingStrategy,
        final String name, final String shortName, final String description, final MonetaryCurrency currency,
        final BigDecimal defaultPrincipal, final BigDecimal defaultMinPrincipal,
        final BigDecimal defaultMaxPrincipal, final BigDecimal defaultNominalInterestRatePerPeriod,
        final BigDecimal defaultMinNominalInterestRatePerPeriod,
        final BigDecimal defaultMaxNominalInterestRatePerPeriod,
        final PeriodFrequencyType interestPeriodFrequencyType,
        final BigDecimal defaultAnnualNominalInterestRate, final InterestMethod interestMethod,
        final InterestCalculationPeriodMethod interestCalculationPeriodMethod,
        final boolean considerPartialPeriodInterest, final Integer repayEvery,
        final PeriodFrequencyType repaymentFrequencyType, final Integer defaultNumberOfInstallments,
        final Integer defaultMinNumberOfInstallments, final Integer defaultMaxNumberOfInstallments,
        final Integer graceOnPrincipalPayment, final Integer recurringMoratoriumOnPrincipalPeriods,
        final Integer graceOnInterestPayment, final Integer graceOnInterestCharged,
        final AmortizationMethod amortizationMethod, final BigDecimal inArrearsTolerance,
        final List<Charge> charges, final AccountingRuleType accountingRuleType,
        final boolean includeInBorrowerCycle, final LocalDate startDate, final LocalDate closeDate,
        final String externalId, final boolean useBorrowerCycle,
        final Set<LoanProductBorrowerCycleVariations> loanProductBorrowerCycleVariations,
        final boolean multiDisburseLoan, final Integer maxTrancheCount, final BigDecimal outstandingLoanBalance,
        final Integer graceOnArrearsAgeing, final Integer overdueDaysForNPA,
        final DaysInMonthType daysInMonthType, final DaysInYearType daysInYearType,
        final boolean isInterestRecalculationEnabled,
        final LoanProductInterestRecalculationDetails productInterestRecalculationDetails,
        final Integer minimumDaysBetweenDisbursalAndFirstRepayment, final boolean holdGuarantorFunds,
        final LoanProductGuaranteeDetails loanProductGuaranteeDetails,
        final BigDecimal principalThresholdForLastInstallment,
        final boolean accountMovesOutOfNPAOnlyOnArrearsCompletion, final boolean canDefineEmiAmount,
        final Integer installmentAmountInMultiplesOf,
        final LoanProductConfigurableAttributes loanProductConfigurableAttributes,
        Boolean isLinkedToFloatingInterestRates, FloatingRate floatingRate, BigDecimal interestRateDifferential,
        BigDecimal minDifferentialLendingRate, BigDecimal maxDifferentialLendingRate,
        BigDecimal defaultDifferentialLendingRate, Boolean isFloatingInterestRateCalculationAllowed,
        final Boolean isVariableInstallmentsAllowed, final Integer minimumGapBetweenInstallments,
        final Integer maximumGapBetweenInstallments, final boolean syncExpectedWithDisbursementDate,
        final boolean canUseForTopup) {
    this.fund = fund;
    this.transactionProcessingStrategy = transactionProcessingStrategy;
    this.name = name.trim();
    this.shortName = shortName.trim();
    if (StringUtils.isNotBlank(description)) {
        this.description = description.trim();
    } else {//from   w  w w  .  java 2s . co  m
        this.description = null;
    }

    if (charges != null) {
        this.charges = charges;
    }

    this.isLinkedToFloatingInterestRate = isLinkedToFloatingInterestRates == null ? false
            : isLinkedToFloatingInterestRates;
    if (isLinkedToFloatingInterestRate) {
        this.floatingRates = new LoanProductFloatingRates(floatingRate, this, interestRateDifferential,
                minDifferentialLendingRate, maxDifferentialLendingRate, defaultDifferentialLendingRate,
                isFloatingInterestRateCalculationAllowed);
    }

    this.allowVariabeInstallments = isVariableInstallmentsAllowed == null ? false
            : isVariableInstallmentsAllowed;

    if (allowVariabeInstallments) {
        this.variableInstallmentConfig = new LoanProductVariableInstallmentConfig(this,
                minimumGapBetweenInstallments, maximumGapBetweenInstallments);
    }

    this.loanProductRelatedDetail = new LoanProductRelatedDetail(currency, defaultPrincipal,
            defaultNominalInterestRatePerPeriod, interestPeriodFrequencyType, defaultAnnualNominalInterestRate,
            interestMethod, interestCalculationPeriodMethod, considerPartialPeriodInterest, repayEvery,
            repaymentFrequencyType, defaultNumberOfInstallments, graceOnPrincipalPayment,
            recurringMoratoriumOnPrincipalPeriods, graceOnInterestPayment, graceOnInterestCharged,
            amortizationMethod, inArrearsTolerance, graceOnArrearsAgeing, daysInMonthType.getValue(),
            daysInYearType.getValue(), isInterestRecalculationEnabled);

    this.loanProductRelatedDetail.validateRepaymentPeriodWithGraceSettings();

    this.loanProductMinMaxConstraints = new LoanProductMinMaxConstraints(defaultMinPrincipal,
            defaultMaxPrincipal, defaultMinNominalInterestRatePerPeriod, defaultMaxNominalInterestRatePerPeriod,
            defaultMinNumberOfInstallments, defaultMaxNumberOfInstallments);

    if (accountingRuleType != null) {
        this.accountingRule = accountingRuleType.getValue();
    }
    this.includeInBorrowerCycle = includeInBorrowerCycle;
    this.useBorrowerCycle = useBorrowerCycle;

    if (startDate != null) {
        this.startDate = startDate.toDateTimeAtStartOfDay().toDate();
    }

    if (closeDate != null) {
        this.closeDate = closeDate.toDateTimeAtStartOfDay().toDate();
    }

    this.externalId = externalId;
    this.borrowerCycleVariations = loanProductBorrowerCycleVariations;
    for (LoanProductBorrowerCycleVariations borrowerCycleVariations : this.borrowerCycleVariations) {
        borrowerCycleVariations.updateLoanProduct(this);
    }
    if (loanProductConfigurableAttributes != null) {
        this.loanConfigurableAttributes = loanProductConfigurableAttributes;
        loanConfigurableAttributes.updateLoanProduct(this);
    }

    this.loanProducTrancheDetails = new LoanProductTrancheDetails(multiDisburseLoan, maxTrancheCount,
            outstandingLoanBalance);
    this.overdueDaysForNPA = overdueDaysForNPA;
    this.productInterestRecalculationDetails = productInterestRecalculationDetails;
    this.minimumDaysBetweenDisbursalAndFirstRepayment = minimumDaysBetweenDisbursalAndFirstRepayment;
    this.holdGuaranteeFunds = holdGuarantorFunds;
    this.loanProductGuaranteeDetails = loanProductGuaranteeDetails;
    this.principalThresholdForLastInstallment = principalThresholdForLastInstallment;
    this.accountMovesOutOfNPAOnlyOnArrearsCompletion = accountMovesOutOfNPAOnlyOnArrearsCompletion;
    this.canDefineInstallmentAmount = canDefineEmiAmount;
    this.installmentAmountInMultiplesOf = installmentAmountInMultiplesOf;
    this.syncExpectedWithDisbursementDate = syncExpectedWithDisbursementDate;
    this.canUseForTopup = canUseForTopup;
}

From source file:com.jjlharrison.jollyday.util.CalendarUtil.java

License:Apache License

/**
 * Searches for the occurrences of a month/day in one chronology within one
 * gregorian year./* w ww  .  j  a va  2s  .c o  m*/
 *
 * @param targetMonth
 * @param targetDay
 * @param gregorianYear
 * @param targetChrono
 * @return the list of gregorian dates.
 */
private Set<LocalDate> getDatesFromChronologyWithinGregorianYear(int targetMonth, int targetDay,
        int gregorianYear, Chronology targetChrono) {
    Set<LocalDate> holidays = new HashSet<LocalDate>();
    LocalDate firstGregorianDate = new LocalDate(gregorianYear, DateTimeConstants.JANUARY, 1,
            ISOChronology.getInstance());
    LocalDate lastGregorianDate = new LocalDate(gregorianYear, DateTimeConstants.DECEMBER, 31,
            ISOChronology.getInstance());

    LocalDate firstTargetDate = new LocalDate(firstGregorianDate.toDateTimeAtStartOfDay().getMillis(),
            targetChrono);
    LocalDate lastTargetDate = new LocalDate(lastGregorianDate.toDateTimeAtStartOfDay().getMillis(),
            targetChrono);

    Interval interv = new Interval(firstTargetDate.toDateTimeAtStartOfDay(),
            lastTargetDate.plusDays(1).toDateTimeAtStartOfDay());

    int targetYear = firstTargetDate.getYear();

    for (; targetYear <= lastTargetDate.getYear();) {
        LocalDate d = new LocalDate(targetYear, targetMonth, targetDay, targetChrono);
        if (interv.contains(d.toDateTimeAtStartOfDay())) {
            holidays.add(convertToISODate(d));
        }
        targetYear++;
    }
    return holidays;
}

From source file:com.jjlharrison.jollyday.util.CalendarUtil.java

License:Apache License

/**
 * Converts the provided date into a date within the ISO chronology. If it
 * is already a ISO date it will return it.
 *
 * @param date//from w  w w .  jav a 2 s.co  m
 *            a {@link org.joda.time.LocalDate} object.
 * @return a {@link org.joda.time.LocalDate} object.
 */
public LocalDate convertToISODate(final LocalDate date) {
    if (!(date.getChronology() instanceof ISOChronology)) {
        return new LocalDate(date.toDateTimeAtStartOfDay().getMillis(), ISOChronology.getInstance());
    }
    return date;
}

From source file:com.manydesigns.elements.util.Util.java

License:Open Source License

public static DateTime parseDateTime(DateTimeFormatter dateTimeFormatter, String input, boolean withTime) {
    if (withTime) {
        return dateTimeFormatter.parseDateTime(input);
    } else {//w ww.  ja v a 2  s.c o  m
        LocalDate localDate = dateTimeFormatter.parseLocalDate(input);
        return localDate.toDateTimeAtStartOfDay();
    }
}

From source file:com.marintek.tpm.dom.todo.ToDoItem.java

License:Apache License

private static boolean isMoreThanOneWeekInPast(final LocalDate dueBy) {
    return dueBy.toDateTimeAtStartOfDay().getMillis() < Clock.getTime() - ONE_WEEK_IN_MILLIS;
}

From source file:com.metinkale.prayerapp.HicriDate.java

License:Apache License

public HicriDate(LocalDate greg) {
    // int[] key = {d, m, y};
    //int[] ret = mCache.get(key);
    //if (ret != null) return ret;
    int hfix = Prefs.getHijriFix();
    if (hfix != 0) {
        greg = greg.plusDays(hfix);/*from   w w  w .j a  va 2s  .c o  m*/
    }
    int d = greg.getDayOfMonth();
    int m = greg.getMonthOfYear();
    int y = greg.getYear();

    int[] last = null;
    for (int[] date : mDates) {
        if (date[GY] < y) {
            last = date;
        } else if ((date[GY] == y) && (date[GM] < m)) {
            last = date;
        } else if ((date[GY] == y) && (date[GM] == m) && (date[GD] <= d)) {
            last = date;
        } else {
            break;
        }
    }
    if (last == null) {
        LocalDate date = greg.toDateTimeAtStartOfDay().withChronology(IslamicChronology.getInstance())
                .toLocalDate();
        Year = date.getYear();
        Month = date.getMonthOfYear();
        Day = date.getDayOfMonth();
    } else {
        int[] h = { last[HD], last[HM], last[HY] };
        h[0] += new LocalDate(y, m, d).getDayOfYear()
                - new LocalDate(last[GY], last[GM], last[GD]).getDayOfYear();
        if ((h[0] >= 30) || (h[0] <= 0)) {
            LocalDate date = greg.toDateTimeAtStartOfDay().withChronology(IslamicChronology.getInstance())
                    .toLocalDate();
            Year = date.getYear();
            Month = date.getMonthOfYear();
            Day = date.getDayOfMonth();
        } else {
            Year = h[HY];
            Month = h[HM];
            Day = h[HD];
        }
    }
}

From source file:com.mysema.query.sql.types.LocalDateType.java

License:Apache License

@Override
public void setValue(PreparedStatement st, int startIndex, LocalDate value) throws SQLException {
    st.setDate(startIndex, new Date(value.toDateTimeAtStartOfDay().getMillis()));
}

From source file:com.ning.billing.invoice.dao.DefaultInvoiceDao.java

License:Apache License

@Override
public List<InvoiceModelDao> getInvoicesByAccount(final UUID accountId, final LocalDate fromDate,
        final InternalTenantContext context) {
    return transactionalSqlDao.execute(new EntitySqlDaoTransactionWrapper<List<InvoiceModelDao>>() {
        @Override/*w  ww  .ja v  a  2  s. c o  m*/
        public List<InvoiceModelDao> inTransaction(
                final EntitySqlDaoWrapperFactory<EntitySqlDao> entitySqlDaoWrapperFactory) throws Exception {
            final InvoiceSqlDao invoiceDao = entitySqlDaoWrapperFactory.become(InvoiceSqlDao.class);

            final List<InvoiceModelDao> invoices = invoiceDao.getInvoicesByAccountAfterDate(
                    accountId.toString(), fromDate.toDateTimeAtStartOfDay().toDate(), context);
            invoiceDaoHelper.populateChildren(invoices, entitySqlDaoWrapperFactory, context);

            return invoices;
        }
    });
}

From source file:com.qcadoo.mes.deviationCausesReporting.DeviationsReportCriteria.java

License:Open Source License

private static DeviationsReportCriteria fromLocalDates(final LocalDate fromDate,
        final Optional<LocalDate> maybeToDate) {
    DateTime rangeBegin = fromDate.toDateTimeAtStartOfDay();
    DateTime rangeEnd = maybeToDate.or(LocalDate.now()).plusDays(1).toDateTimeAtStartOfDay().minusMillis(1);
    Preconditions.checkArgument(rangeBegin.isBefore(rangeEnd), "Passed dates have wrong order.");
    Interval searchInterval = new Interval(rangeBegin, rangeEnd);
    return new DeviationsReportCriteria(searchInterval);
}