Implements exceptions on Java Digital Clock : <p>i try to develop digital clock using java. i still new in java. the problem is, i try to implement exception on my code but i did not know how to make it.</p>

<p>my make code as below</p>

<p>Main Class</p>

<pre><code>import java.awt.Color;
import java.awt.FlowLayout;
import java.awt.Font;
import javax.swing.JFrame;
import javax.swing.JLabel;


public class DigitalClock extends JFrame {

JLabel jLabClock;
ClockThread ct;

public DigitalClock(){
    JFrame f = new JFrame("Digital Clock");
    jLabClock = new JLabel("00:00:00 AM");
    f.getContentPane().setBackground(Color.BLACK);
    f.setLayout(new FlowLayout());
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    jLabClock.setFont(new Font("DS-Digital", Font.BOLD, 50));
    jLabClock.setForeground(new java.awt.Color(15, 245, 15));
    f.add(jLabClock);
    f.pack();
    f.setLocationRelativeTo(null);
    ct = new ClockThread(this);
    f.setVisible(true);
    f.setResizable(false);

}


public static void main(String[] args) {
    DigitalClock digitalClock = new DigitalClock();
}
}
</code></pre>

<p>Thread Class</p>

<pre><code>import java.util.Calendar;
import java.util.GregorianCalendar;



public class ClockThread extends Thread{

DigitalClock dc;
int timeRun = 0;

public ClockThread(DigitalClock dc){

    this.dc = dc;
    start();
}

@Override
public void run(){

    while(timeRun == 0){

        Calendar cal = new GregorianCalendar();

        int hour = cal.get(Calendar.HOUR);
        int min = cal.get(Calendar.MINUTE);
        int sec = cal.get(Calendar.SECOND);
        int am_pm = cal.get(Calendar.AM_PM);

        String day_night = "";

        if (am_pm == 1){
            day_night = "PM";
        }
        else{
            day_night = "AM";
        }
        String time = hour + ":" + min + ":" + sec + " " + day_night;

        dc.jLabClock.setText(time);
    }

}
}
</code></pre>

<p>this code work fine to me but i just want to try use exception on my code. can somebody help me, please</p>
