We need the Graphics class because that will paint the clock display. You may wonder why we do not use the Date class to read the current time. Date has been depreciated. Calendar is now the preferred class to use. We will now examine these classes and methods in more detail.
Lets examine the code.
The code will be in red and comments will be in blue . Any commentary will be in regular text. This is what paints the clock on the screen. Take the current hour and do some tests on it. If the hour is under '10', that is to say one digit, then add a '0' in front of the digit.