Your condition is wrong. When you write this:

if (newHour > -1 || newHour < 24) {

You really mean this:

if (newHour > -1 && newHour < 24) {
Answer from nicomp on Stack Overflow
🌐
Oracle
docs.oracle.com › javase › 8 › docs › api › java › time › Clock.html
Clock (Java Platform SE 8 )
1 week ago - If not overridden, the behavior is defined by Object.equals(java.lang.Object) Overrides: equals in class Object · Parameters: obj - the object to check, null returns false · Returns: true if this is equal to the other clock · See Also: Object.hashCode(), HashMap · public int hashCode() A hash code for this clock.
🌐
Baeldung
baeldung.com › home › java › java dates › guide to the java clock class
Guide to the Java Clock Class | Baeldung
August 19, 2025 - Clock was added in Java 8 and provides access to an instant in time using the best available system clock, and to be used as a time provider which can be effectively stubbed for testing purposes.
🌐
Oracle
docs.oracle.com › en › java › javase › 21 › docs › api › java.base › java › time › Clock.html
Clock (Java SE 21 & JDK 21)
January 20, 2026 - Clocks should override this method to compare equals based on their state and to meet the contract of Object.equals(java.lang.Object). If not overridden, the behavior is defined by Object.equals(java.lang.Object) ... A hash code for this clock.
🌐
GitHub
github.com › bpupadhyaya › openjdk-8 › blob › master › jdk › src › share › classes › java › time › Clock.java
openjdk-8/jdk/src/share/classes/java/time/Clock.java at master · bpupadhyaya/openjdk-8
import java.util.TimeZone; · /** * A clock providing access to the current instant, date and time using a time-zone. * <p> * Instances of this class are used to find the current instant, which can be · * interpreted using the stored time-zone to find the current date and time. * As such, a clock can be used instead of {@link System#currentTimeMillis()} * and {@link TimeZone#getDefault()}. * <p> * Use of a {@code Clock} is optional.
Author   bpupadhyaya
🌐
W3C
w3.org › International › Clock.java
Clock.java
January 17, 2023 - // modified 97/07/22 Bert Bos: made into Component instead of Applet // modified 11/03/21 Bert Bos: added a package to make it compile with Java6 import java.util.*; import java.awt.*; import java.awt.event.*; import java.applet.*; import java.text.*; public class Clock extends Panel implements Runnable, ComponentListener { private static final int MINDIST = 49000; private static final float MIND = 0.4f; private static final double TH = 0.18; private Thread timer; private int lastxs = 0, lastys = 0; // Seconds hand private int lastxm = 0, lastym = 0; // Minutes hand private int lastxd = 0, las
🌐
GeeksforGeeks
geeksforgeeks.org › java › clock-system-method-in-java-with-examples
Clock system() Method in Java with Examples - GeeksforGeeks
January 17, 2023 - Program 2: Create Clock with Zone ... ZoneId.of("US/Arizona"); // Create a Clock instance with the system(zoneId) method Clock clock = Clock.system(zoneId); // Print details of the ZoneId of the new Clock System.out.println("ZoneID ...
🌐
SMU
cs.smu.ca › ~porter › csc › 228 › code › Savitch4thEd › lab_manual › 13 › Clock.java2html
Source of Clock.java
public Clock(int h, int m, int s) 17: { 18: setHour(h); 19: setMinute(m); 20: setSecond(s); 21: } 22: 23:
Find elsewhere
🌐
Oracle
docs.oracle.com › en › java › javase › 18 › docs › api › java.base › java › time › Clock.html
Clock (Java SE 18 & JDK 18)
August 18, 2022 - Clocks should override this method to compare equals based on their state and to meet the contract of Object.equals(java.lang.Object). If not overridden, the behavior is defined by Object.equals(java.lang.Object) ... A hash code for this clock.
🌐
Oracle
docs.oracle.com › en › java › javase › 17 › docs › api › java.base › java › time › Clock.html
Clock (Java SE 17 & JDK 17)
October 20, 2025 - Clocks should override this method to compare equals based on their state and to meet the contract of Object.equals(java.lang.Object). If not overridden, the behavior is defined by Object.equals(java.lang.Object) ... A hash code for this clock.
🌐
EDUCBA
educba.com › home › software development › software development tutorials › java tutorial › java clock
Java Clock | Learn The Top Five Methods of Java Clock
June 23, 2022 - To conclude, we have understood that the Java Clock class was introduced in Java 8. It provides instant if the current system’s Time and Date. We understood the methods along with the proper syntax and a clear explanation. We worked out two examples with code to demonstrate these methods, one for two methods related to Zone and Instant methods and another for the equals method.
Address   Unit no. 202, Jay Antariksh Bldg, Makwana Road, Marol, Andheri (East),, 400059, Mumbai
🌐
Oracle
docs.oracle.com › en › java › javase › 23 › docs › api › java.base › java › time › Clock.html
Clock (Java SE 23 & JDK 23)
October 17, 2024 - Clocks should override this method to compare equals based on their state and to meet the contract of Object.equals(java.lang.Object). If not overridden, the behavior is defined by Object.equals(java.lang.Object) ... A hash code for this clock.
🌐
C# Corner
c-sharpcorner.com › UploadFile › 433c33 › creating-analog-clock-in-java
Creating Analog Clock in Java
September 17, 2019 - clock.start(); } Complete Code · import java.awt.Color; import java.awt.Font; import java.awt.Graphics; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Locale; import javax.swing.JFrame; import javax.swing.JPanel; public class Clock extends JPanel implements Runnable ·
🌐
YouTube
youtube.com › watch
Java clock app 🕓 - YouTube
Java, clock, program, app, swing, GUI, tutorial, beginners,#Java #clock #program #app #swing #GUI #tutorial #beginners//https://docs.oracle.com/javase/7/docs...
Published   September 6, 2020
🌐
GeeksforGeeks
geeksforgeeks.org › java › java-clock-tickminutes-method-in-java-with-examples
Java Clock tickMinutes() method in Java with Examples - GeeksforGeeks
August 6, 2020 - Below programs illustrates tickMinutes() method of java.time.Clock class: Program 1: When Clock is created with Zone "Asia/Calcutta" for printing instant of clock ticking in whole minute.
🌐
Oracle
docs.oracle.com › javase › 8 › docs › api › java › time › class-use › Clock.html
Uses of Class java.time.Clock (Java Platform SE 8 )
October 20, 2025 - Submit a bug or feature For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
🌐
Oracle
docs.oracle.com › en › java › javase › 22 › docs › api › java.base › java › time › Clock.html
Clock (Java SE 22 & JDK 22)
July 16, 2024 - Clocks should override this method to compare equals based on their state and to meet the contract of Object.equals(java.lang.Object). If not overridden, the behavior is defined by Object.equals(java.lang.Object) ... A hash code for this clock.
🌐
Medium
medium.com › @aleksanderkolata › time-travel-in-java-do-you-have-a-clock-3c9060059561
Time travel in Java - do you have a Clock? | by Aleksander Kołata | Medium
September 4, 2022 - using java.time.Clock class as a time provider - it makes testing easier and it makes time travel possible