Example usage for org.joda.time LocalDate toString

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

Introduction

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

Prototype

public String toString(String pattern) 

Source Link

Document

Output the date using the specified format pattern.

Usage

From source file:org.gnucash.android.ui.report.LineChartFragment.java

License:Apache License

/**
 * Returns a data object that represents a user data of the specified account types
 * @param accountTypeList account's types which will be displayed
 * @return a {@code LineData} instance that represents a user data
 *///from   w w  w  .j av a 2s .  c  o  m
private LineData getData(List<AccountType> accountTypeList) {
    Log.w(TAG, "getData");
    calculateEarliestAndLatestTimestamps(accountTypeList);
    // LocalDateTime?
    LocalDate startDate;
    LocalDate endDate;
    if (mReportStartTime == -1 && mReportEndTime == -1) {
        startDate = new LocalDate(mEarliestTransactionTimestamp).withDayOfMonth(1);
        endDate = new LocalDate(mLatestTransactionTimestamp).withDayOfMonth(1);
    } else {
        startDate = new LocalDate(mReportStartTime).withDayOfMonth(1);
        endDate = new LocalDate(mReportEndTime).withDayOfMonth(1);
    }

    int count = getDateDiff(new LocalDateTime(startDate.toDate().getTime()),
            new LocalDateTime(endDate.toDate().getTime()));
    Log.d(TAG, "X-axis count" + count);
    List<String> xValues = new ArrayList<>();
    for (int i = 0; i <= count; i++) {
        switch (mGroupInterval) {
        case MONTH:
            xValues.add(startDate.toString(X_AXIS_PATTERN));
            Log.d(TAG, "X-axis " + startDate.toString("MM yy"));
            startDate = startDate.plusMonths(1);
            break;
        case QUARTER:
            int quarter = getQuarter(new LocalDateTime(startDate.toDate().getTime()));
            xValues.add("Q" + quarter + startDate.toString(" yy"));
            Log.d(TAG, "X-axis " + "Q" + quarter + startDate.toString(" MM yy"));
            startDate = startDate.plusMonths(3);
            break;
        case YEAR:
            xValues.add(startDate.toString("yyyy"));
            Log.d(TAG, "X-axis " + startDate.toString("yyyy"));
            startDate = startDate.plusYears(1);
            break;
        //                default:
        }
    }

    List<LineDataSet> dataSets = new ArrayList<>();
    for (AccountType accountType : accountTypeList) {
        LineDataSet set = new LineDataSet(getEntryList(accountType), accountType.toString());
        set.setDrawFilled(true);
        set.setLineWidth(2);
        set.setColor(COLORS[dataSets.size()]);
        set.setFillColor(FILL_COLORS[dataSets.size()]);

        dataSets.add(set);
    }

    LineData lineData = new LineData(xValues, dataSets);
    if (lineData.getYValueSum() == 0) {
        mChartDataPresent = false;
        return getEmptyData();
    }
    return lineData;
}

From source file:org.isisaddons.module.settings.dom.jdo.ApplicationSettingsServiceJdo.java

License:Apache License

@Action(domainEvent = NewLocalDateDomainEvent.class, semantics = SemanticsOf.NON_IDEMPOTENT)
@ActionLayout(cssClassFa = "plus")
@MemberOrder(sequence = "1.3.4")
@Override//from   ww  w  .ja v a 2s  . c  o m
public ApplicationSettingJdo newLocalDate(@ParameterLayout(named = "Key") final String key,
        @Parameter(optionality = Optionality.OPTIONAL) @ParameterLayout(named = "Description") final String description,
        @ParameterLayout(named = "Value") final LocalDate value) {
    return newSetting(key, description, SettingType.LOCAL_DATE, value.toString(SettingAbstract.DATE_FORMATTER));
}

From source file:org.isisaddons.module.settings.dom.jdo.SettingAbstractJdo.java

License:Apache License

@Action(domainEvent = UpdateAsLocalDateDomainEvent.class)
public SettingAbstractJdo updateAsLocalDate(@ParameterLayout(named = "Value") final LocalDate value) {
    setValueRaw(value.toString(DATE_FORMATTER));
    return this;
}

From source file:org.isisaddons.module.settings.dom.jdo.UserSettingsServiceJdo.java

License:Apache License

@Action(domainEvent = NewLocalDateDomainEvent.class, semantics = SemanticsOf.NON_IDEMPOTENT)
@ActionLayout(cssClassFa = "plus")
@MemberOrder(sequence = "2.3.4")
public UserSettingJdo newLocalDate(@ParameterLayout(named = "User") final String user,
        @ParameterLayout(named = "Key") final String key,
        @Parameter(optionality = Optionality.OPTIONAL) @ParameterLayout(named = "Description") final String description,
        @ParameterLayout(named = "Value") final LocalDate value) {
    return newSetting(user, key, description, SettingType.LOCAL_DATE,
            value.toString(SettingAbstract.DATE_FORMATTER));
}

From source file:org.jahap.gui.MainGuiFx.java

License:Open Source License

public void initialize(URL url, ResourceBundle rb) {
    DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd.MM.yy");
    CurrentUser cu = CurrentUser.getCurrentUser();
    Hotelbean hbean = new Hotelbean();
    LocalDate hdate = LocalDate.fromDateFields(hbean.getOperationdate());
    this.hotelday.setText(hdate.toString("dd.MM.yy"));

    System.out.print(cu.isIsAdmin());

    System.out.print(com.sun.javafx.runtime.VersionInfo.getVersion());

}

From source file:org.libreplan.importers.tim.TimLocalDateAdapter.java

License:Open Source License

@Override
public String marshal(LocalDate localDate) throws Exception {
    return localDate.toString("dd-MM-yyyy");
}

From source file:org.libreplan.web.users.dashboard.PersonalTimesheetDTO.java

License:Open Source License

/**
 * Returns a string representing the personal timehseet in a given
 * <code>date</code> depending on the <code>periodicity</code>.
 */// ww  w .  j a v  a2 s. c o m
public static String toString(PersonalTimesheetsPeriodicityEnum periodicity, LocalDate date) {
    switch (periodicity) {

    case WEEKLY:
        LocalDate start = periodicity.getStart(date);
        LocalDate end = periodicity.getEnd(date);

        String string = date.toString("w");
        if (start.getMonthOfYear() == end.getMonthOfYear()) {
            string += " (" + date.toString(MMMM_Y_PATTERN) + ")";
        } else {
            if (start.getYear() == end.getYear()) {
                string += " (" + start.toString("MMMM") + " - " + end.toString(MMMM_Y_PATTERN) + ")";
            } else {
                string += " (" + start.toString(MMMM_Y_PATTERN) + " - " + end.toString(MMMM_Y_PATTERN) + ")";
            }
        }
        return _("Week {0}", string);

    case TWICE_MONTHLY:
        return (date.getDayOfMonth() <= 15) ? _("{0} 1st fortnight", date.toString(MMMM_Y_PATTERN))
                : _("{0} 2nd fortnight", date.toString(MMMM_Y_PATTERN));

    case MONTHLY:
    default:
        return date.toString(MMMM_Y_PATTERN);
    }
}

From source file:org.mifos.application.servicefacade.LoanAccountServiceFacadeWebTier.java

License:Open Source License

@Override
public Errors validateLoanDisbursementDate(LocalDate loanDisbursementDate, Integer customerId,
        Integer productId) {/*from   w  w  w.ja va  2 s . c  om*/

    Errors errors = new Errors();

    if (loanDisbursementDate.isBefore(new LocalDate())) {
        String[] args = { "" };
        errors.addError("dibursementdate.cannot.be.before.todays.date", args);
    }

    CustomerBO customer = this.customerDao.findCustomerById(customerId);
    LocalDate customerActivationDate = new LocalDate(customer.getCustomerActivationDate());
    if (loanDisbursementDate.isBefore(customerActivationDate)) {
        String[] args = { customerActivationDate.toString("dd-MMM-yyyy") };
        errors.addError("dibursementdate.before.customer.activation.date", args);
    }

    LoanOfferingBO loanProduct = this.loanProductDao.findById(productId);
    LocalDate productStartDate = new LocalDate(loanProduct.getStartDate());
    if (loanDisbursementDate.isBefore(productStartDate)) {
        String[] args = { productStartDate.toString("dd-MMM-yyyy") };
        errors.addError("dibursementdate.before.product.startDate", args);
    }

    try {
        this.holidayServiceFacade.validateDisbursementDateForNewLoan(customer.getOfficeId(),
                loanDisbursementDate.toDateMidnight().toDateTime());
    } catch (BusinessRuleException e) {
        String[] args = { "" };
        errors.addError("dibursementdate.falls.on.holiday", args);
    }

    boolean isRepaymentIndependentOfMeetingEnabled = new ConfigurationBusinessService()
            .isRepaymentIndepOfMeetingEnabled();

    LoanDisbursementDateFactory loanDisbursementDateFactory = new LoanDisbursmentDateFactoryImpl();
    LoanDisbursementDateValidator loanDisbursementDateFinder = loanDisbursementDateFactory.create(customer,
            loanProduct, isRepaymentIndependentOfMeetingEnabled, false);

    boolean isValid = loanDisbursementDateFinder
            .isDisbursementDateValidInRelationToSchedule(loanDisbursementDate);
    if (!isValid) {
        String[] args = { "" };
        errors.addError("dibursementdate.invalid.in.relation.to.meeting.schedule", args);
    }

    return errors;
}

From source file:org.mifos.application.servicefacade.LoanAccountServiceFacadeWebTier.java

License:Open Source License

@Override
public Errors validateLoanWithBackdatedPaymentsDisbursementDate(LocalDate loanDisbursementDate,
        Integer customerId, Integer productId) {
    Errors errors = new Errors();

    if (!loanDisbursementDate.isBefore(new LocalDate())) {
        String[] args = { "" };
        errors.addError("dibursementdate.before.todays.date", args);
    }/*from  w w w.jav  a2  s . c o  m*/

    CustomerBO customer = this.customerDao.findCustomerById(customerId);
    LocalDate customerActivationDate = new LocalDate(customer.getCustomerActivationDate());
    if (loanDisbursementDate.isBefore(customerActivationDate)) {
        String[] args = { customerActivationDate.toString("dd-MMM-yyyy") };
        errors.addError("dibursementdate.before.customer.activation.date", args);
    }

    LoanOfferingBO loanProduct = this.loanProductDao.findById(productId);
    LocalDate productStartDate = new LocalDate(loanProduct.getStartDate());
    if (loanDisbursementDate.isBefore(productStartDate)) {
        String[] args = { productStartDate.toString("dd-MMM-yyyy") };
        errors.addError("dibursementdate.before.product.startDate", args);
    }

    try {
        this.holidayServiceFacade.validateDisbursementDateForNewLoan(customer.getOfficeId(),
                loanDisbursementDate.toDateMidnight().toDateTime());
    } catch (BusinessRuleException e) {
        String[] args = { "" };
        errors.addError("dibursementdate.falls.on.holiday", args);
    }

    return errors;
}

From source file:org.mifos.test.acceptance.framework.loan.LoanAccountPage.java

License:Open Source License

public void verifyLastNoteDate(LocalDate date) {
    String noteDateString = selenium.getText("//td[@id='recentNotes']/span[1]").trim().replace(":", "");
    Assert.assertEquals(noteDateString, date.toString("dd/MM/yyyy"));
}