• Post Reply Bookmark Topic Watch Topic
  • New Topic

Convert a String to a Timestamp  RSS feed

 
brad balmer
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • 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.
 
Layne Lund
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
  • 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
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!