title: Check current date java
body: <p>From java class <a href="https://docs.oracle.com/javase/8/docs/api/java/util/Date.html" rel="nofollow noreferrer">Date</a> docs:</p>
  
  <blockquote>
    <p>before(Date when) Tests if this date is before the specified date.</p>
  </blockquote>
  
  <p>When I use this method to test whether selected date is equal to today, I get <code>wrong</code> output message. </p>
  
  <pre><code>public class JavaApplication28 {
  
      /**
       * @param args the command line arguments
       */
      public static void main(String[] args) throws NoSuchAlgorithmException, ParseException {
  
          Date date1;
          SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
          String statusDT ="2018-04-08";
          date1 = formatter.parse(statusDT);
          if (date1.equals(new Date())) {
              System.out.println("today");
          } else if (date1.before(new Date())) {
              System.out.println("wrong");
          }
      }
  }
  </code></pre>
  
  <p>This is date1, which is today date</p>
  
  <pre><code>Sun Apr 08 00:00:00 MYT 2018
  </code></pre>
  
  <p>The equal method look not functiong as well</p>
  
  <blockquote>
    <p>equals(Object obj) Compares two dates for equality.</p>
  </blockquote>