Example usage for org.joda.time YearMonth isBefore

List of usage examples for org.joda.time YearMonth isBefore

Introduction

In this page you can find the example usage for org.joda.time YearMonth isBefore.

Prototype

public boolean isBefore(ReadablePartial partial) 

Source Link

Document

Is this partial earlier than the specified partial.

Usage

From source file:de.topobyte.joda.utils.MonthSpan.java

License:Open Source License

/**
 * Create a new span of months with the specified bounds.
 * //  w  w  w .  j a  v a 2s . c om
 * @param limitLower
 *            the lower limit, inclusive
 * @param limitUpper
 *            the upper limit, exclusive
 */
public MonthSpan(YearMonth limitLower, YearMonth limitUpper) {
    this.limitLower = limitLower;
    this.limitUpper = limitUpper;

    empty = !limitLower.isBefore(limitUpper);
}

From source file:de.topobyte.joda.utils.MonthSpan.java

License:Open Source License

/**
 * @return whether the specified month is within this span.
 *///w  ww.  ja v  a 2s. c o m
public boolean contains(YearMonth month) {
    if (empty) {
        return false;
    }

    return !month.isBefore(limitLower) && month.isBefore(limitUpper);
}

From source file:org.alexlg.bankit.controllers.AccountController.java

License:Open Source License

/**
 * Build categories summary for each month from startDate
 * to previous nbPrevMonth//from w ww .  j a va2  s.c  o m
 * @param startDate Start the summary for this month
 * @param endDate Stop the summary for this month
 * @return Map with the date of the month and a Map with Category
 *          and amount for this category for this month
 */
protected Map<Date, Map<Category, BigDecimal>> buildCategories(LocalDate startDate, LocalDate endDate) {
    Map<Date, Map<Category, BigDecimal>> categories = new LinkedHashMap<Date, Map<Category, BigDecimal>>();

    YearMonth curMonth = null; //month we start to retrieve
    YearMonth endMonth = null; //last month we have to retrieve
    if (startDate.isBefore(endDate)) {
        curMonth = new YearMonth(startDate.getYear(), startDate.getMonthOfYear());
        endMonth = new YearMonth(endDate.getYear(), endDate.getMonthOfYear());
    } else {
        curMonth = new YearMonth(endDate.getYear(), endDate.getMonthOfYear());
        endMonth = new YearMonth(startDate.getYear(), startDate.getMonthOfYear());
    }

    do {
        Map<Category, BigDecimal> monthSummary = categoryDao.getMonthSummary(curMonth);
        if (monthSummary.size() > 0) {
            categories.put(curMonth.toLocalDate(1).toDate(), monthSummary);
        }
        curMonth = curMonth.plusMonths(1);
    } while (curMonth.isBefore(endMonth) || curMonth.isEqual(endMonth));

    return categories;
}