Example usage for org.joda.time YearMonth minusMonths

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

Introduction

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

Prototype

public YearMonth minusMonths(int months) 

Source Link

Document

Returns a copy of this year-month minus the specified number of months.

Usage

From source file:org.openmrs.module.mirebalaisreports.fragment.controller.field.MonthSinceMirebalaisOpeningFragmentController.java

License:Open Source License

public void controller(FragmentModel model) {
    List<SimpleObject> months = new ArrayList<SimpleObject>();

    YearMonth earliest = new YearMonth(2013, 2);
    YearMonth month = new YearMonth().minusMonths(1);
    while (month.isAfter(earliest)) {
        months.add(SimpleObject.create("label", month.toString("MMM yyyy", Context.getLocale()), "value",
                month.toString("yyyy-MM-01")));
        month = month.minusMonths(1);
    }//from ww  w  .ja va2 s.  com
    model.addAttribute("months", months);
}