You can get today's date or current date and time in Java by creating a new Date() object. A java.uti.Date object represents the current date and time instance in Java. Now, if you want to date in DDMMYYYY format or any other date format, you can easily convert the Date object to String by using SimpleDateFormat class. Since Date instance contains both date and time, if you only need a date then you can further convert the java.util.Date to java.sql.Date. Similarly, if you need just time then you can convert the java.util.Date to java.sql.Time, they represent the date and time part of java.util.Date object in Java. You can also use the java.util.Calendar class to get the today's date and time. Further, if you are using Java 8 then you can use new Date and Time API classes like LocalDate, LocalTime, and LocalDateTime to get the current date, time, and date-time in Java.
Read more »