Example usage for org.joda.time Months parseMonths

List of usage examples for org.joda.time Months parseMonths

Introduction

In this page you can find the example usage for org.joda.time Months parseMonths.

Prototype

@FromString
public static Months parseMonths(String periodStr) 

Source Link

Document

Creates a new Months by parsing a string in the ISO8601 format 'PnM'.

Usage

From source file:griffon.plugins.jodatime.editors.MonthsPropertyEditor.java

License:Apache License

private void handleAsString(String str) {
    if (isBlank(str)) {
        super.setValueInternal(null);
        return;/*from ww  w .  j ava 2 s.c  om*/
    }

    try {
        super.setValueInternal(parse(Integer.parseInt(str)));
        return;
    } catch (NumberFormatException nfe) {
        // ignore
    }

    try {
        super.setValueInternal(Months.parseMonths(str));
    } catch (IllegalArgumentException e) {
        throw illegalValue(str, Months.class, e);
    }
}