Results 1 to 3 of 3

Thread: Java Clock

  1. #1

    Default Java Clock


    I am making a simple clock using Java that display......

    The current time in hours:minutes:seconds and the current date.

    I googled for this,but I get codes in applet form. I don't know how to start.

    I have this code below that returns the date and time as a string. It get the local system time.
    My problem is to display it in the GUI with the display moving.

    I tried to put a Label in the GUI and set it with the returned value

    Code:
    TimeLabel.setText(DateTime.now);
    It displays but its just stationary.
    I tried to use an infinite loop on it but the code wouldn't build.

    Code:
    public class DateTime{
        public static final String DATE_FORMAT_NOW = "yyyy-MM-dd HH:mm:ss";
    
        public static String now() {
            Calendar cal = Calendar.getInstance();
            SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT_NOW);
            return sdf.format(cal.getTime());
    
        }
    }
    Also, Can I use the returned String to insert in a MSSQL database?

  2. #2
    Elite Member
    Join Date
    Aug 2008
    Posts
    1,053
    Blog Entries
    1
    if you like to see it running, you should use different threads...

    java.util.Timer
    java.awt.event.ActionListener

  3. #3
    Thanks bro. Solved na. ^^

  4.    Advertisement

Similar Threads

 
  1. Advance Java
    By gloryhunter in forum Programming
    Replies: 25
    Last Post: 11-15-2007, 10:14 AM
  2. SE K500i 3D Java Games/Application.. (?)
    By mE_bytes in forum Gizmos & Gadgets (Old)
    Replies: 1
    Last Post: 07-14-2005, 11:14 PM
  3. Java Seminar
    By polie in forum Business, Finance & Economics Discussions
    Replies: 5
    Last Post: 07-09-2005, 01:38 AM
  4. Mobile Java Games
    By Nezumix22 in forum Gizmos & Gadgets (Old)
    Replies: 23
    Last Post: 05-06-2005, 05:33 PM
  5. how to install java apps/games in motorola c651
    By 8088 in forum Gizmos & Gadgets (Old)
    Replies: 4
    Last Post: 04-18-2005, 03:40 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
about us
We are the first Cebu Online Media.

iSTORYA.NET is Cebu's Biggest, Southern Philippines' Most Active, and the Philippines' Strongest Online Community!
follow us
#top