We're updating the issue view to help you get more done. 

Literal gyear with value 1 calendarValue bugs

Description

The following test currently fails.

1 2 3 4 5 6 @Test public void testGYear1() throws Exception { assertEquals(new LiteralImpl("1", XMLSchema.GYEAR).calendarValue().getYear(), 1); }

This can be fixed in the LiteralImpl class using the following workarround.

1 2 3 4 5 6 7 public XMLGregorianCalendar calendarValue() { if (XMLSchema.GYEAR.equals(datatype)) { return XMLDatatypeUtil.parseGYear(getLabel()); } else { return XMLDatatypeUtil.parseCalendar(getLabel()); } }

And then adding the following method in the XMLDatatypeUtil

1 2 3 4 5 6 7 8 9 10 11 12 13 14 /** * Parses the supplied gyear value string and returns its value. * This is a work around for gyears 1 * @param s * A string representation of an xsd:gYear value. * @return The calendar value represented by the supplied string argument. * @throws NumberFormatException * If the supplied string is not a valid calendar value. */ public static XMLGregorianCalendar parseGYear(String s) { final XMLGregorianCalendar newXMLGregorianCalendar = dtFactory.newXMLGregorianCalendar(); newXMLGregorianCalendar.setYear(Integer.parseInt(s)); return newXMLGregorianCalendar; }

Environment

None

Status

Assignee

JeenB

Reporter

Jerven Bolleman

Labels

Components

Fix versions

Affects versions

2.7.10

Priority

Minor