• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Convert a String to a Timestamp

 
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm tring to do this originally using the jakarta commons classes, but I don't have to.

I'm trying to convert a String into a Timestamp using:

ConvertUtils.register(new SqlTimestampConverter(), Timestamp.class);
try {
timestamp = (Timestamp)ConvertUtils.convert(fullStringTimestamp,
Timestamp.class);
}catch(Exception E) {
E.printStackTrace();
}

The fullStringTimestamp value is 2005-02-03 03:30.000000000

Could anybody please point me in the right direction as this is throwing a org.apache.commons.beanutils.ConversionException.

Or using any of the plain java classes?

Thanks.
 
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Perhaps DateFormat and SimpleDateFormat would be able to solve your problem more easily. These classes are part of the standard Java API.

Keep Coding!

-Layne
 
reply
    Bookmark Topic Watch Topic
  • New Topic