I am trying to do it without methods so that I can better grasp the concept.
I am really close. My hours math seems to be off. What am I not understanding there?
static void showCurrent(){
Date today = new Date();
long milliseconds = today.getTime(); // ex: 1651773923837
long seconds = milliseconds / 1000;
long minutes = seconds / 60;
long hours = minutes / 60;
long s = seconds % 60;
long m = minutes % 60;
long h = hours % 24;
System.out.printf("Date: %s, Time: %d\n", today.toString(), milliseconds);
System.out.println(h + ": " + m + ": " + s );
Output:
Date: Fri May 06 10:13:21 EDT 2022, Time: 1651846401839
14: 13: 21