Initial commit
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
package com.thoughtworks.xstream.converters.time;
|
||||
|
||||
import com.thoughtworks.xstream.converters.ConversionException;
|
||||
import com.thoughtworks.xstream.converters.basic.AbstractSingleValueConverter;
|
||||
import java.time.Year;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class YearConverter extends AbstractSingleValueConverter {
|
||||
@Override // com.thoughtworks.xstream.converters.basic.AbstractSingleValueConverter, com.thoughtworks.xstream.converters.ConverterMatcher
|
||||
public boolean canConvert(Class cls) {
|
||||
return Year.class == cls;
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.converters.basic.AbstractSingleValueConverter, com.thoughtworks.xstream.converters.SingleValueConverter
|
||||
public Year fromString(String str) {
|
||||
try {
|
||||
return Year.of(Integer.parseInt(str));
|
||||
} catch (NumberFormatException e) {
|
||||
ConversionException conversionException = new ConversionException("Cannot parse value as year", e);
|
||||
conversionException.add("value", str);
|
||||
throw conversionException;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user