EN
Java - get current date of java.util.Date class
18
points
In this short article, we would like to show how to get the current date and time of java.util.Date
class.
Quick solution:
// import java.util.Date;
Date now = new Date();
System.out.println(now.toString()); // Wed Aug 11 16:11:42 CEST 2021
Practical example
import java.util.Date;
public class Program {
public static void main(String[] args) {
Date now = new Date();
System.out.println(now.toString()); // Wed Aug 11 16:11:42 CEST 2021
}
}
Example output:
Wed Aug 11 16:11:42 CEST 2021