Get actual date in Java
Question:
How to get actual date in Java? Answer:
Date today = new Date();
// In string format
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
String todayStr = formatter.format(new Date());
Description:
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.
Reference:
Java Date reference
Share "How to get actual date in Java?"
Related snippets:
- Get the last Friday of a month in Java
- Get the first Monday of a month in Java
- Get the first day of the week in Java
- Get the first day of the current month in Java
- Get the last day of a month in Java
- Get the number of days between two dates in Java
- Get yesterday's date in Java
- Get tomorrow's date in Java
- Get actual date in Java
Tags:
actual date, todays date, current date Technical term:
Get actual date in Java