[ http://issues.apache.org/jira/browse/TUSCANY-579?page=all ]
Brian Murray updated TUSCANY-579:
---------------------------------
Attachment: Tuscany579.patch
The attached patch will allow both getString and setString on a Date value.
The format of the Date resulting from getString is
"yyyy'-'MM'-'dd'T'H':'mm':'ss.S" as indicated in the spec. The required format
of the input String to allow setString to function is
"yy'-'MM'-'dd'T'H':'mm':'ss.S". (The difference between the two is that four
year digits are output from getString, but only two year digits are required as
input for setString. Also as indicated in the spec the optional trailing Z may
also be provided to setString.)
If the string is not of the required format for setString on a Date field, an
IllegalArgumentException will result with the following message:
java.lang.IllegalArgumentException: The following string is not in SDO Date
format: <input string>
An IllegalArgumentException was chosen because it is the exception that results
from the now deprecated Date constructor with a string argument, in the event
of a poorly formatted string input.
> getString on Date field results in IllegalArgumentException
> -----------------------------------------------------------
>
> Key: TUSCANY-579
> URL: http://issues.apache.org/jira/browse/TUSCANY-579
> Project: Tuscany
> Issue Type: Bug
> Components: Java SDO Implementation
> Reporter: Brian Murray
> Assigned To: Frank Budinsky
> Attachments: Tuscany579.patch
>
>
> On page 146 of V2.01 of the spec, it is stated that conversion from Date to
> String is supported. However, getString on Date type results in an
> IllegalArgumentException. Here is a code segment:
> public void testShowErrorsInSimpleFormat() throws Exception
> {
> DataObject test_obj = DataFactory.INSTANCE.create(API_TEST_TYPE);
> Date current_date = new Date(System.currentTimeMillis());
> // getString does not work on Date type
> test_obj.setDate("dateVal", current_date);
> String returned_string = test_obj.getString("dateVal"); //Gives
> IllegalArgumentException
> }
> And here is the XSD:
> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
> xmlns:sdo="commonj.sdo"
> xmlns:simple="http://www.example.com/api_test"
> targetNamespace="http://www.example.com/api_test">
> <xsd:import namespace="commonj.sdo" schemaLocation="sdoModel.xsd"/>
> <xsd:element name="apiTestElem" type="simple:APITest"/>
> <xsd:complexType mixed="true" name="APITest">
> <xsd:sequence>
> <xsd:element name="stringVal" type="sdo:String"/>
> <xsd:element name="booleanVal" type="sdo:Boolean"/>
> <xsd:element name="booleanVal2" type="sdo:Boolean"/>
> <xsd:element name="byteVal" type="sdo:Byte"/>
> <xsd:element name="stringVal2" type="sdo:String"/>
> <xsd:element name="decimalVal" type="sdo:Decimal"/>
> <xsd:element name="decimalVal2" type="sdo:Decimal"/>
> <xsd:element name="intVal" type="sdo:Int"/>
> <xsd:element name="floatVal" type="sdo:Float"/>
> <xsd:element name="doubleVal" type="sdo:Double"/>
> <xsd:element name="dateVal" type="sdo:Date"/>
> <xsd:element name="shortVal" type="sdo:Short"/>
> <xsd:element name="longVal" type="sdo:Long"/>
> <xsd:element maxOccurs="unbounded" minOccurs="0"
> name="children" type="simple:APITest"/>
> <xsd:element name="bytesVal" type="sdo:Bytes"/>
> <xsd:element name="integerVal" type="sdo:Integer"/>
> <xsd:element name="charVal" type="sdo:Character"/>
> </xsd:sequence>
> </xsd:complexType>
> I originally thought that also getDate was not working on String, but this
> was an error in my test case. I had been setting the String value to be
> Date.toString(). Fuhwei correctly pointed out that the String format that
> would allow conversion is given on page 72 of the specification and is
> different than what is returned by Date.toString(). I have tested with the
> correct String format and found that getDate works, so clearly this is not an
> error. However, I wonder if it would be a good idea to aditionally support
> the String format that results from Date.toString().
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]