title: How to compare date from java to mysql
body: <p>Hi I want to know how we can compare a current date from java with stored date in mysql.</p>
  
  <p>date stored in MySQL is <code>2013-01-04 13:15:00</code></p>
  
  <p>when i compare this date in java by getting current date </p>
  
  <pre><code>Date date = new Date();
  </code></pre>
  
  <p>then wrote a query if the date stored in MySQL is less than current display the result. but query is returning 0 result.</p>
  
  <pre><code>select model from abc model where model.abcStartDate &gt;= date and model.abcEndDate &amp;gt;= date
  </code></pre>
  
  <p>In the MySQL The start date and end date are of timestamp data type.</p>
  
  <p>Below is the EJB entity class</p>
  
  <pre><code>@Entity
  @Table(name = "abc_table", uniqueConstraints = {})
  public class ABCClass implements java.io.Serializable {
  
  private static final long serialVersionUID = -1924961655993587546L;
  
  // Fields
  private Date abcStartDate;
  private Date abcEndDate;
  
  // Constructors
  
  /** default constructor */
  public ABCClass() {
  }
  
  
  @OrderBy(value="3")
  @Temporal(TemporalType.TIMESTAMP)
  @Column(name = "abc_start_date", unique = false, nullable = false, insertable = true, updatable = true, length = 19)
  public Date getabcStartDate() {
      return this.abcStartDate;
  }
  
  public void setabcStartDate(Date abcStartDate) {
      this.abcStartDate = abcStartDate;
  }
  
  @OrderBy(value="4")
  @Temporal(TemporalType.TIMESTAMP)
  @Column(name = "abc_end_date", unique = false, nullable = false, insertable = true, updatable = true, length = 19)
  public Date getabcEndDate() {
      return this.abcEndDate;
  }
  
  public void setabcEndDate(Date abcEndDate) {
      this.abcEndDate = abcEndDate;
  }
  
  }
  </code></pre>