class JodaTimeSingleFieldPeriodConverter extends AbstractConverter {

    @Override
    public Object convert(Object source, TypeToken<?> targetTypeToken) {
        if (!canHandle(source, targetTypeToken)) {
            throw new ConverterException(source, targetTypeToken.getRawType());
        }

        Integer period = null;
        if (source instanceof Number) {
            period = (Integer) numberToNumberConverter.convert(source, TypeToken.of(Integer.class));
        } else if (source instanceof String) {
            period = (Integer) stringToNumberConverter.convert(source, TypeToken.of(Integer.class));
        }

        Type targetType = targetTypeToken.getType();

        if (targetType.equals(Seconds.class)) {
            return Seconds.seconds(period);
        } else if (targetType.equals(Minutes.class)) {
            return Minutes.minutes(period);
        } else if (targetType.equals(Hours.class)) {
            return Hours.hours(period);
        } else if (targetType.equals(Days.class)) {
            return Days.days(period);
        } else if (targetType.equals(Weeks.class)) {
            return Weeks.weeks(period);
        } else if (targetType.equals(Months.class)) {
            return Months.months(period);
        } else if (targetType.equals(Years.class)) {
            return Years.years(period);
        }

        throw new ConverterException(source, targetTypeToken.getRawType());
    }

}