Example usage for org.joda.time PeriodType getFieldType

List of usage examples for org.joda.time PeriodType getFieldType

Introduction

In this page you can find the example usage for org.joda.time PeriodType getFieldType.

Prototype

public DurationFieldType getFieldType(int index) 

Source Link

Document

Gets the field type by index.

Usage

From source file:com.addthis.basis.time.Dates.java

License:Apache License

/**
 * Convenience method to create a new single field period of arbitrary type
 * (e.g. 10 days, 6 months, etc.)/*from www.j  a va2  s. c om*/
 * <p/>
 * Requires that type be a single field period
 *
 * @param length
 * @param type
 * @return
 */
public static Period period(int length, PeriodType type) {
    return new Period(null, type).withField(type.getFieldType(0), length);
}

From source file:net.sourceforge.fenixedu.presentationTier.renderers.DurationRenderer.java

License:Open Source License

private DurationFieldType[] getDurationFieldTypes() {
    List<DurationFieldType> result = new ArrayList<DurationFieldType>();
    if (getIncludedFields() == null) {
        result.add(DurationFieldType.hours());
        result.add(DurationFieldType.minutes());
    } else {/*from  w w w  .jav  a  2  s .c om*/
        PeriodType standard = PeriodType.standard();
        for (int index = 0; index < standard.size(); index++) {
            if (getIncludedFields().contains(standard.getFieldType(index).getName())) {
                result.add(standard.getFieldType(index));
            }
        }
    }
    return result.toArray(new DurationFieldType[] {});
}