title: Current datetime in Joda-Time date formatting for mysql timestamp
body: <p>I need to import the current date and time into a MySQL database field whose format is <a href="http://dev.mysql.com/doc/refman/5.7/en/datetime.html" rel="nofollow">TimeStamp</a>.  From examining sample data, it seems that the format for the MySQL TimeStamp datatype is "yyyy-mm-dd hh:mm:ss".  I am using <a href="http://www.joda.org/joda-time/" rel="nofollow">Joda-Time</a> formatting in my spring hibernate application.  How do I get the current date time in a format that will be accepted by the underlying MySQL TimeStamp formatted field?  </p>
  
  <p>Here is my current code, which will not compile because eclipse says .parseDateTime() requires a string argument and not a DateTime argument:  </p>
  
  <pre><code>public void setCreated(){
      DateTime now = new org.joda.time.DateTime();
      DateTimeFormatter fmt = DateTimeFormat.forPattern("yyyy-MM-dd hh:mm:ss");
      created = fmt.parseDateTime(now);
      System.out.println("'''''''''''''''''''''' created is: "+created);
  }
  </code></pre>
  
  <p>The entity that I am trying to persist is defined as follows:  </p>
  
  <pre><code>@Entity
  @Table(name = "documents")
  public class Document {
  @Id
  @GeneratedValue
  @Column(name="id")
  private Integer id;
  
  @ManyToOne
  @JoinColumn(name = "client_id")
  private Patient patient;
  
  @ManyToOne
  @JoinColumn(name = "type_id")
  private DocumentType type;
  
  @Column(name="name")
  private String name;
  
  @Column(name="description")
  private String description;
  
  @Column(name="filename")
  private String filename;
  
  @Column(name="content")
  @Lob
  private Blob content;
  
  @Column(name="content_type")
  private String contentType;
  
  @Column(name = "created")
  private DateTime created;
  
  public Integer getId(){return id;}
  public void setId(Integer i){id=i;}
  
  protected void setPatient(Patient patient) {this.patient = patient;}
  public Patient getPatient(){return this.patient;}
  
  public void setType(DocumentType type) {this.type = type;}
  public DocumentType getType() {return this.type;}
  
  public String getName(){return name;}
  public void setName(String nm){name=nm;}
  
  public String getDescription(){return description;}
  public void setDescription(String desc){description=desc;}
  
  public String getFileName(){return filename;}
  public void setFileName(String fn){filename=fn;}
  
  public Blob getContent(){return content;}
  public void setContent(Blob ct){content=ct;}
  
  public String getContentType(){return contentType;}
  public void setContentType(String ctype){contentType=ctype;}
  
  public void setCreated(){
      DateTime now = new org.joda.time.DateTime();
      DateTimeFormatter fmt = DateTimeFormat.forPattern("yyyy-MM-dd hh:mm:ss");
      created = fmt.parseDateTime(now);
  System.out.println("''''''''''''''''''''''''''' created is: "+created);
  }
  public DateTime getCreated() {return this.created;}
  
  @Override
  public String toString() {return this.getName();}
  public boolean isNew() {return (this.id == null);}
  
  }
  </code></pre>
  
  <p>How do I change the above so that it saves data in the correct format for insertion into a MySQL TimeStamp field?</p>
  
  <hr>
  
  <h2>EDIT:</h2>
  
  <p>Related to Sotirios' suggestion, here are relevant portions to my current pom.xml for discussion purposes:  </p>
  
  <pre><code>&lt;properties&gt;
      &lt;jodatime-hibernate.version&gt;1.3&lt;/jodatime-hibernate.version&gt;
      &lt;jodatime-jsptags.version&gt;1.1.1&lt;/jodatime-jsptags.version&gt;
      &lt;jodatime.version&gt;2.3&lt;/jodatime.version&gt;
      &lt;jadira-usertype-core.version&gt;3.1.0.CR8&lt;/jadira-usertype-core.version&gt;
  &lt;/properties&gt;
  &lt;dependencies&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.jadira.usertype&lt;/groupId&gt;
          &lt;artifactId&gt;usertype.core&lt;/artifactId&gt;
          &lt;version&gt;${jadira-usertype-core.version}&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;joda-time&lt;/groupId&gt;
          &lt;artifactId&gt;joda-time&lt;/artifactId&gt;
          &lt;version&gt;${jodatime.version}&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;joda-time&lt;/groupId&gt;
          &lt;artifactId&gt;joda-time-hibernate&lt;/artifactId&gt;
          &lt;version&gt;${jodatime-hibernate.version}&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;joda-time&lt;/groupId&gt;
          &lt;artifactId&gt;joda-time-jsptags&lt;/artifactId&gt;
          &lt;version&gt;${jodatime-jsptags.version}&lt;/version&gt;
      &lt;/dependency&gt;
  &lt;/dependencies&gt;
  </code></pre>