Use java's new date code example
Example: how to create date class in java
// This creates a new Date instance with current system time. Internally It uses System.currentTimeMillis()
Date date = new Date();
// This creates a new Date instance with time that you specify in milliseconds since the epoch time
Date date = new Date(1672556400000L); // This time is Jan 1 2023 in GMT