axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "David D. Lucas" <ddlu...@lse.com>
Subject Re: xsd:dateTime parse
Date Thu, 13 May 2004 14:39:27 GMT
You are probably using the default DateFormat format.
Try using something like this:

   SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd'T'hh:mm:ssZ"); 
//check the format in the JavaDoc for this
   Date date = sdf.parse(value);

Keep in mind sdf can be expensive and you might want to cache these.

Best wishes,
Dave



Yu, Joel, Contractor wrote:
> The exception message is:
> 
> java.text.ParseException: Unparseable date: "2004-05-12T00:00:00-05:00"
> 
> -----Original Message-----
> From: Steve Loughran [mailto:steve_l@iseran.com]
> Sent: Thursday, May 13, 2004 6:44 AM
> To: axis-dev@ws.apache.org
> Subject: Re: xsd:dateTime parse
> 
> 
> 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
> 

-- 

+------------------------------------------------------------+
| David Lucas                      mailto: ddlucas @ lse.com |
| Lucas Software Engineering, Inc.   (740) 964-6248 Voice    |
| Unix,Java,C++,CORBA,XML,EJB        (614) 668-4020 Mobile   |
| Middleware,Frameworks              (888) 866-4728 Fax/Msg  |
+------------------------------------------------------------+
| GPS Location:  40.0150 deg Lat,  -82.6378 deg Long         |
| IMHC: "Jesus Christ is the way, the truth, and the life."  |
| IMHC: "I know where I am; I know where I'm going."    <><  |
+------------------------------------------------------------+

Notes: PGP Key Block=http://www.lse.com/~ddlucas/pgpblock.txt
IMHO="in my humble opinion" IMHC="in my humble conviction"
All trademarks above are those of their respective owners.


Mime
View raw message