Java Code Examples for org.joda.time.LocalDate.minusYears()

The following are Jave code examples for showing how to use minusYears() of the org.joda.time.LocalDate class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: citizen-sdk-android   File: TokenService.java   Source Code and License Vote up 5 votes
@NonNull
public static List getTokenDurationAsStringList(LocalDate expiry, String year, String month, String day) {// Get months
    LocalDate start = new LocalDate(DateTime.now());
    int years = Years.yearsBetween(start, expiry).getYears();
    // Subtract this number of years from the end date so we can calculate days
    expiry = expiry.minusYears(years);
    int months = Months.monthsBetween(start, expiry).getMonths();
    // Subtract this number of months from the end date so we can calculate days
    expiry = expiry.minusMonths(months);
    // Get days
    int days = Days.daysBetween(start, expiry).getDays();

    String y = null, m = null, d = null;

    List list = new ArrayList();

    if (years > 0) {
        y = years + year;
        list.add(y);
    }
    if (months > 0) {
        m = months + month;
        list.add(m);
    }
    if (days > 0) {
        d = days + day;
        list.add(d);
    }
    return list;
}