Re: about the date format: "2005-03-02 11:55:33.0"
Posted by: Mark Matthews
Date: March 03, 2005 10:51AM

Simon Haldon wrote:
> I also now get a '.0' on the end of my dates of
> format DATETIME returned to a jsp.

Simon,

DATETIMEs are mapped to JDBC TIMESTAMPs. They will get formatted as such (which includes the .0 at the end), as that's required by the JDBC spec. In order to support some SQL and JDBC standards, Connector/J 3.1 converts values to timestamps if they are of DATETIME or TIMESTAMP type, even when calling .getString().

You should never, ever rely on the default format of a built-in type in Java to remain the same, as they change from time-to-time (case in point, BigDecimal.toString() is different between JDK-1.4 and 1.5).

If you need a specific format for display in your application then you really should use something like SimpleDateFormat, as it's the only guaranteed way to have consistent formatting.

-Mark

Mark Matthews
Consulting Member Technical Staff - MySQL Enterprise Tools
Oracle
http://www.mysql.com/products/enterprise/monitor.html

Options: ReplyQuote


Subject
Written By
Posted
Re: about the date format: "2005-03-02 11:55:33.0"
March 03, 2005 10:51AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.