File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes A Ticking Clock Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "A Ticking Clock" Watch "A Ticking Clock" New topic

A Ticking Clock

Rajesh Chandra
Ranch Hand

Joined: Jun 13, 2005
Posts: 55
Hi friends,
im out to make a ticking clock (console based).With Calendar class and Date class in java.util ,can we get the time(ie hours, minutes and seconds separately??).if we manage to get these data is it possible to show it in the console with the clock updating itself dynamically?
In nutshell is it possible to make a clock like we have in our computers at the bottom right.
Joanne Neal

Joined: Aug 05, 2005
Posts: 3742
Read the API

As far as displaying it in the console is concerned, I assume you want each update to overwrite the previous one rather than be on a new line each time. If so then you need a way to manipulate the cursor position. This isn't possible in standard Java, but I believe there is a package called JCurses or JavaCurses that may do this for you.

Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
is this what you're trying to do?

Rajesh Chandra
Ranch Hand

Joined: Jun 13, 2005
Posts: 55
Thank u so much. It is exactly what i wanted.Can u explain it in detail how it works?
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 15091


It's a very simple program, it's not hard to understand.

You really need to have a good look at the API documentation. Lookup the classes and interfaces used in the code (such as java.text.SimpleDateFormat and java.util.Timer) in the documentation and read about how they work.

Please do some work yourself instead of expecting that someone will explain every little detail for you - if you find out for yourself, you'll learn more.

If you don't fully understand the basics of the Java language yet (classes, interfaces, methods, loops, etc.), have a look at The Java Tutorial.
[ September 29, 2005: Message edited by: Jesper de Jong ]

Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
I agree. Here's the link:
subject: A Ticking Clock
It's not a secret anymore!