Java console code for StopWatch/Timer?
<p>I have the required code for the stopwatch here. All i want is get rid of the Swing part here and display the same output in console. Can anybody help?    </p>

<pre><code>import java.awt.event.*;
import javax.swing.*;
import java.awt.*;
import java.text.*;

public class ElapsedTime extends JFrame
{
JLabel time;

long startTime = System.currentTimeMillis();

ElapsedTime()
{
setSize(380,200);
setTitle("http://simpleandeasycodes.blogspot.com/");
setLocation(100,100);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

setLayout(new GridBagLayout());

time = new JLabel("");

time.setFont(new Font("SansSerif",Font.BOLD, 36));

time.setForeground(Color.MAGENTA);

add(time);

//starting new Thread which will update time
new Thread(new Runnable()
{
public void run() 
{ try 
{
updateTime(); 
} 
catch (Exception ie) 
{ }
}
}).start();
}

public void updateTime()
{
try
{
while(true)
{
//geting Time in desire format
time.setText(getTimeElapsed());
//Thread sleeping for 1 sec
Thread.currentThread().sleep(1000);
}
}
catch (Exception e)
{
System.out.println("Exception in Thread Sleep : "+e);
}
}

public String getTimeElapsed()
{
long elapsedTime = System.currentTimeMillis() - startTime;
elapsedTime = elapsedTime / 1000;

String seconds = Integer.toString((int)(elapsedTime % 60));
String minutes = Integer.toString((int)((elapsedTime % 3600) / 60));
String hours = Integer.toString((int)(elapsedTime / 3600));

if (seconds.length() &lt; 2)
seconds = "0" + seconds;

if (minutes.length() &lt; 2)
minutes = "0" + minutes;

if (hours.length() &lt; 2)
hours = "0" + hours;

return minutes+":"+seconds;
}

public static void main(String[] args) 
{
JFrame obj = new ElapsedTime();
obj.setVisible(true);
}
}
</code></pre>
