Re: Fw: How to date type conversion between xml and Java

Jason Hunter <[email protected]>
Newsgroups gmane.comp.java.jdom.general
Message-ID <[email protected]>
Use java.text.SimpleDateFormat.  It can parse the date string, lets you interact with it as data, and helps you reformat it if you need.

Note it's relatively slow because of its complex internals.  If your dates are always in the exact same simple format like you showed, and you need to parse a huge number of them, a simple custom parser based on character positions can be much faster.

-jh-

On Aug 15, 2010, at 8:41 PM, Jack Bush wrote:

> Hi All,
> 
> 
> I need some advice on how to store the following date value from a xhtml 
> document using JPA:
> 
>  <p>    
>      <strong>Time:</strong> 
>      <time>13/08/2010 00:10:19 am</time> 
>  </p>
> 
> There is no problem retrieving this value using XPath query. However, the value 
> returned is of type string yet JPA (futureStock.setCollectionTime()) expects 
> type java.util.Date such as the following code snippet:
> 
>    org.jdom.Element collection_time = 
> ((org.jdom.Element)time_element).getChild("time");
>    futureStock.setCollectionTime(collection_time.getTextNormalize());
> 
> I would like to be in a position to retrieve both date and time separately and 
> date comparison at a 
> 
> later stage.
> 
> Any idea on how to overcome this issue? 
> Thanks a lot,
> Jack
> 
> 
> 
> 
> 
> _______________________________________________
> To control your jdom-interest membership:
> http://www.jdom.org/mailman/options/jdom-interest/[email protected]


_______________________________________________
To control your jdom-interest membership:
http://www.jdom.org/mailman/options/jdom-interest/[email protected]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.