You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by "Yu, Joel, Contractor" <Jo...@asamra.hoffman.army.mil> on 2004/05/11 21:27:03 UTC

xsd:dateTime parse

The following is code generated by wsdl2java for xsd:dateTime type.  It is
unalbe to parse date of xsd:dateTime format.  I am getting a
java.text.ParseException.  I am using axis 1.1 and jdk 1.4.  How can I
change the following code so it will parse xsd:dateTime format.

thanks


    public DateTimeType(java.lang.String value) {
        java.util.Calendar cal = java.util.Calendar.getInstance();
        try {
          java.util.Date dt =
(java.text.DateFormat.getDateTimeInstance()).parse(value);  <-- throws
exception
          cal.setTime(dt);
          this.value = cal;
        }
        catch (java.text.ParseException e){
            throw new java.lang.RuntimeException(e.toString());
        }
    }

Re: xsd:dateTime parse

Posted by Steve Loughran <st...@iseran.com>.
Yu, Joel, Contractor wrote:
> The following is code generated by wsdl2java for xsd:dateTime type.  It is
> unalbe to parse date of xsd:dateTime format.  I am getting a
> java.text.ParseException.  I am using axis 1.1 and jdk 1.4.  How can I
> change the following code so it will parse xsd:dateTime format.
> 
> thanks
> 
> 
>     public DateTimeType(java.lang.String value) {
>         java.util.Calendar cal = java.util.Calendar.getInstance();
>         try {
>           java.util.Date dt =
> (java.text.DateFormat.getDateTimeInstance()).parse(value);  <-- throws
> exception
>           cal.setTime(dt);
>           this.value = cal;
>         }
>         catch (java.text.ParseException e){
>             throw new java.lang.RuntimeException(e.toString());
>         }
>     }

What do the values coming in look like? It may really be a legit failure 
handled ungracefully.

-steve