26 lines
1.1 KiB
Java
26 lines
1.1 KiB
Java
package com.thoughtworks.xstream.converters.time;
|
|
|
|
import com.thoughtworks.xstream.converters.ConversionException;
|
|
import com.thoughtworks.xstream.converters.basic.AbstractSingleValueConverter;
|
|
import java.time.Period;
|
|
import java.time.format.DateTimeParseException;
|
|
|
|
/* loaded from: classes.dex */
|
|
public class PeriodConverter extends AbstractSingleValueConverter {
|
|
@Override // com.thoughtworks.xstream.converters.basic.AbstractSingleValueConverter, com.thoughtworks.xstream.converters.ConverterMatcher
|
|
public boolean canConvert(Class cls) {
|
|
return Period.class == cls;
|
|
}
|
|
|
|
@Override // com.thoughtworks.xstream.converters.basic.AbstractSingleValueConverter, com.thoughtworks.xstream.converters.SingleValueConverter
|
|
public Period fromString(String str) {
|
|
try {
|
|
return Period.parse(str);
|
|
} catch (DateTimeParseException e) {
|
|
ConversionException conversionException = new ConversionException("Cannot parse period value", e);
|
|
conversionException.add("period", str);
|
|
throw conversionException;
|
|
}
|
|
}
|
|
}
|