tags:

views:

120

answers:

3
+1  Q: 

digital clock

any builtin classes available to display the digital clock in java??

+2  A: 

i dont think there are any built in, but they are pretty easy to develop. there is a swing timer utility that you can use. here is a demo

akf
thank u!! its a good example
A: 

No, not that I'm aware of.

However, assuming the use of Swing, one could use the JLabel class or the like use its setText method to show display the current time. (Another option is to extend the JLabel to display the current time as well.)

If one needs to actually make a subclass of JComponent which displays a seven-segment digit-like display by writing a custom paintComponent method to draw the digits.

coobird
A: 

You can print the date and time with

System.out.println(new java.util.Date());
Thorbjørn Ravn Andersen