Java Date FAQ: Can you show me how to get today's date in Java?
Getting a Java Date object that represents "today" or "now" is fairly simple. The following sample code shows how to do this:
Date date = Calendar.getInstance().getTime();
If you haven't worked with the Java Date class before, I should point out that I'm referring to a java.util.Date
class here, and not a java.sql.Date
class. To make this a little more clear, I could write that same code like this: