Date currentDate = new Date(); System.out.println(currentDate);
long timestamp = 1625928365000L; Date specificDate = new Date(timestamp); System.out.println(specificDate);
Date currentDate = new Date(); SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String formattedDate = dateFormat.format(currentDate); System.out.println(formattedDate);This code will create a new Date object representing the current date and time, then format it as a string in the format "yyyy-MM-dd HH:mm:ss", and then print the formatted string to the console. The java.util.Date class is part of the Java Standard Library, specifically the java.util package.