title: print current date in java
body: <p>I want to print current date and time in java..This is the code I am trying from a java tutorial:</p>
  <pre><code>import java.util.*;
    
  public class Date {
     public static void main(String args[]) {
         // Instantiate a Date object
         Date date = new Date();
          
         // display time and date using toString()
         System.out.println(date.toString());
     }
  }
  </code></pre>
  <p>It compiles fine. But the output given is:</p>
  <blockquote>
  <p>Date@15db9742</p>
  </blockquote>
  <p>While i am expecting a output like this:</p>
  <blockquote>
  <p>Mon May 04 09:51:52 CDT 2009</p>
  </blockquote>
  <p>What is wrong with the code?</p>
  <p>EDIT:
  I tried to rename the class.. The editted code:</p>
  <pre><code>import java.util.*;
    
  public class DateDemo {
     public static void main(String args[]) {
         // Instantiate a Date object
         Date d = new Date();
          
         // display time and date using toString()
         System.out.println(d.toString());
     }
  }
  </code></pre>
  <p>This is how I compiled the code and ran:</p>
  <blockquote>
  <p>sou@sou-linux:~/Desktop/java$ javac DateDemo.java</p>
  <p>sou@sou-linux:~/Desktop/java$ java DateDemo</p>
  </blockquote>
  <p>The output is:</p>
  <blockquote>
  <p>Date@15db9742</p>
  </blockquote>