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:
xxxxxxxxxx
1
// import java.util.Date;
2
3
Date now = new Date();
4
System.out.println(now.toString()); // Wed Aug 11 16:11:42 CEST 2021
xxxxxxxxxx
1
import java.util.Date;
2
3
public class Program {
4
5
public static void main(String[] args) {
6
7
Date now = new Date();
8
System.out.println(now.toString()); // Wed Aug 11 16:11:42 CEST 2021
9
}
10
}
Example output:
xxxxxxxxxx
1
Wed Aug 11 16:11:42 CEST 2021