Example usage for org.joda.time YearMonth toString

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

Introduction

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

Prototype

public String toString(String pattern, Locale locale) throws IllegalArgumentException 

Source Link

Document

Output the year-month using the specified format pattern.

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);//ww  w. j  a v a  2 s.  co m
    }
    model.addAttribute("months", months);
}