Announcement Announcement Module
Collapse
No announcement yet.
JodaTime DateTimeFormatter not applied to java.sql.Timestamp Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • JodaTime DateTimeFormatter not applied to java.sql.Timestamp

    I'm using Spring 3.0.5 and I've noticed that timestamps are not formatted correctly when printed using <spring:eval/>.
    The fields are defined as java.util.Date but at runtime they contain a java.sql.Timestamp because of the JPA implemention used (Hibernate 3.6):

    Code:
    @Column(nullable = false)
    @Temporal(TemporalType.TIMESTAMP)
    protected java.util.Date created;
    If I define the accessor like this, the field gets not formatted by JodaTime:
    Code:
    @DateTimeFormat(style = "MM")
    public java.util.Date getCreated() {
       return created; // this returns a java.sql.Timestamp instance
    }
    But if I convert the field to java.util.Date it does get formatted:
    Code:
    @DateTimeFormat(style = "MS")
    public java.util.Date getCreated() {
       return (created != null ? new java.util.Date(created.getTime()) : null);
    }
    So my question is whether there's a bug introduced in 3.0.5 or are formatters not applied to subclasses by design?
    If so, would it be enough to register a converter between Date and Timestamp or do I have to register a JodaTime converter for Timestamp explicitly?

    Thanks in advance!

    Robin.
    Last edited by robin; Jan 7th, 2011, 07:02 AM.

  • #2
    No one?
    Does anybody know whether formatters should be applied to sub-classes?

    Comment

    Working...
    X