Example usage for org.joda.time Period minusYears

List of usage examples for org.joda.time Period minusYears

Introduction

In this page you can find the example usage for org.joda.time Period minusYears.

Prototype

public Period minusYears(int years) 

Source Link

Document

Returns a new period with the specified number of years taken away.

Usage

From source file:com.jbirdvegas.mgerrit.search.AgeSearch.java

License:Apache License

/**
 * Calculates the number of days spanned in a period assuming 365 days per year, 30 days per
 * month, 7 days per week, 24 hours per day, 60 minutes per hour and 60 seconds per minute.
 * @param period A period to retrieve the number of standard days for
 * @return The number of days spanned by the period.
 *//*from   w  w  w.j a v  a 2 s . co m*/
protected static int getDaysInPeriod(final Period period) {
    int totalDays = 0;
    Period temp = new Period(period);
    if (period.getYears() > 0) {
        int years = period.getYears();
        totalDays += 365 * years;
        temp = temp.minusYears(years);
    }
    if (period.getMonths() > 0) {
        int months = period.getMonths();
        totalDays += 30 * period.getMonths();
        temp = temp.minusMonths(months);
    }
    return totalDays + temp.toStandardDays().getDays();
}