- Instant help with your Java coding problems

Get actual date in Java

How to get actual date in Java?
Date today = new Date();

// In string format
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
String todayStr = formatter.format(new Date());

In Java, you can get the actual date by simply creating a new Date object. If you want to get a nicely formatted string representation of the date, use the SimpleDateFormat class with the appropriate format string.

Java Date reference
Share "How to get actual date in Java?"