Example usage for org.joda.time Period withPeriodType

List of usage examples for org.joda.time Period withPeriodType

Introduction

In this page you can find the example usage for org.joda.time Period withPeriodType.

Prototype

public Period withPeriodType(PeriodType type) 

Source Link

Document

Creates a new Period instance with the same field values but different PeriodType.

Usage

From source file:org.jadira.usertype.dateandtime.joda.columnmapper.StringColumnPeriodMapper.java

License:Apache License

@Override
public Period fromNonNullValue(String s) {

    int separatorIndex = s.indexOf('{');
    if (separatorIndex == -1) {
        return new Period(s);
    } else {/*w w w. j  av a 2s.  co  m*/
        Period period = new Period(s.substring(0, separatorIndex));
        return period.withPeriodType(determinePeriodType(s.substring(separatorIndex + 1, s.length() - 1)));
    }
}