I want to print current date and time in java..This is the code I am trying from a java tutorial:
import java.util.*;
public class Date {
public static
You are getting the default toString() from Object because you created your own class named Date which is hiding the imported Date from java.util.. You can rename your class or you can use the canonical name java.util.Date like
public static void main(String args[]) {
java.util.Date date = new java.util.Date();
System.out.println(date);
}
Output here is
Mon Nov 03 10:57:45 EST 2014