Example usage for org.joda.time Period minusMonths

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

Introduction

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

Prototype

public Period minusMonths(int months) 

Source Link

Document

Returns a new period minus the specified number of months 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.
 *///ww w  .j a  va  2  s. c o 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();
}