Before JDK 8, the solution must focus on the java.util.Date class. The code that is bundled to this book contains this solution.
Starting with JDK 8, the date and time can be obtained via the dedicated classes, LocalDate and LocalTime, from the java.time package:
// 2019-02-24
LocalDate onlyDate = LocalDate.now();
// 12:53:28.812637300
LocalTime onlyTime = LocalTime.now();