United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: 7055530 XMLGregorianCalendar: wrong behaviour of setXXX methods
7055530 : XMLGregorianCalendar: wrong behaviour of setXXX methods

Details
Type:
Bug
Submit Date:
2011-06-16
Status:
Closed
Updated Date:
2012-06-09
Project Name:
JDK
Resolved Date:
2011-09-08
Component:
xml
OS:
generic
Sub-Component:
jaxp
CPU:
generic
Priority:
P3
Resolution:
Not an Issue
Affected Versions:
7
Fixed Versions:
8

Related Reports

Sub Tasks

Description
Problem Description from IBM:
The expectation that an exception be thrown contradicts all other behaviour of XMLGregorianCalendar where the user can set the values of fields in many ways where the value while they're editing may be invalid, for example setting the value of days = 31 in month 2 (i.e. Feburary 31st) before reassigning the month value to something else.

A user calling the methods individually,

XMLGregorianCalendar.setHour(24);
XMLGregorianCalendar.setMinute(0);
XMLGregorianCalendar.setSecond(1);

wouldn't get an exception.

XMLGregorianCalendar.setTime(24, 0, 1);

is just short-hand for that sequence of calls. It should behave the same way as all the other set() methods and not throw an exception.

                                    

Comments
EVALUATION

It seemed warranted that the behavior of individual field setters, such as setHour, should be consistent with those that affects multiple fields, such as setTime.

However, I would agree with the original design that validates values of each fields in their own context. For a single field setter, the value needs to be validated against the constraints of that field. For methods that affect multiple fields, the constraints would be an aggregation of all fields. The specification clearly defined time(24,0,0) following XML Schema errata e2-45 (http://www.w3.org/2001/05/xmlschema-errata#e2-45), and therefore required the setTime method to report (24,0,1) as a violation.

*** (#1 of 1): [ UNSAVED ] ###@###.###
                                     
2011-09-08



Hardware and Software, Engineered to Work Together