Example usage for org.joda.time.format ISOPeriodFormat alternate

List of usage examples for org.joda.time.format ISOPeriodFormat alternate

Introduction

In this page you can find the example usage for org.joda.time.format ISOPeriodFormat alternate.

Prototype

public static PeriodFormatter alternate() 

Source Link

Document

The alternate ISO format, PyyyymmddThhmmss, which excludes weeks.

Usage

From source file:colossal.pipe.BaseOptions.java

License:Apache License

private Period parseDuration() {
    PeriodFormatter[] toTry = { PeriodFormat.getDefault(), ISOPeriodFormat.standard(),
            ISOPeriodFormat.alternate(), ISOPeriodFormat.alternateExtended(),
            ISOPeriodFormat.alternateExtendedWithWeeks(), ISOPeriodFormat.alternateWithWeeks() };
    for (PeriodFormatter f : toTry) {
        try {//from ww w  . j a v a  2  s  . com
            return f.parsePeriod(duration);
        } catch (IllegalArgumentException iae) {
            // skip to next
        }
    }
    throw new IllegalArgumentException("Can't parse: " + duration);
}