Skip to content

Commit 60b6375

Browse files
committed
Refactor some constant
1 parent 4b863b6 commit 60b6375

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/org/beanio/types/xml/AbstractXmlCalendarTypeHandler.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@
3131
*/
3232
public abstract class AbstractXmlCalendarTypeHandler extends CalendarTypeHandler {
3333

34-
protected static final DatatypeFactory dataTypeFactory;
34+
private static final String DATE_TIME = "dateTime";
35+
private static final String INVALID_XML = "Invalid XML ";
36+
protected static final DatatypeFactory dataTypeFactory;
3537
static {
3638
try {
3739
dataTypeFactory = DatatypeFactory.newInstance();
@@ -67,20 +69,20 @@ public Calendar parse(String text) throws TypeConversionException {
6769
try {
6870
XMLGregorianCalendar xcal = dataTypeFactory.newXMLGregorianCalendar(text);
6971
if (!lenientDatatype && type != null && !xcal.getXMLSchemaType().equals(type)) {
70-
throw new TypeConversionException("Invalid XML " + type.getLocalPart());
72+
throw new TypeConversionException(INVALID_XML + type.getLocalPart());
7173
}
7274

7375
if (!isTimeZoneAllowed() && xcal.getTimezone() != DatatypeConstants.FIELD_UNDEFINED) {
74-
String typeName = type == null ? "dateTime" : type.getLocalPart();
75-
throw new TypeConversionException("Invalid XML " + typeName +
76+
String typeName = type == null ? DATE_TIME : type.getLocalPart();
77+
throw new TypeConversionException(INVALID_XML + typeName +
7678
", time zone not allowed");
7779
}
7880

7981
return xcal.toGregorianCalendar();
8082
}
8183
catch (IllegalArgumentException ex) {
82-
String typeName = type == null ? "dateTime" : type.getLocalPart();
83-
throw new TypeConversionException("Invalid XML " + typeName);
84+
String typeName = type == null ? DATE_TIME : type.getLocalPart();
85+
throw new TypeConversionException(INVALID_XML + typeName);
8486
}
8587
}
8688

0 commit comments

Comments
 (0)