public class Clock
public static void main(String args)
ClockViewAnalog cv = new ClockViewAnalog();
// loop about every 0.5 seconds
catch (Exception e)
now = java.util.Calendar.getInstance();
hrs = now.get(java.util.Calendar.HOUR_OF_DAY);
mins = now.get(java.util.Calendar.MINUTE);
secs = now.get(java.util.Calendar.SECOND);
it show time exactly what i want but it doesnt actually work on the am pm thing
Rishal Dev Singh wrote:it show time exactly what i want but it doesnt actually work on the am pm thing
First: Please UseCodeTags (←click - and please read the page thoroughly; you may need to break up some of those long lines).
Second: Isolate the problem.
You're trying to display the time as AM/PM, so do that first and get it working before you add in all that GUI stuff.
Third: Have a look at the documentation for Calendar.HOUR_OF_DAY. Why do you think it might not be what you want?
Fourth: Have a look at the docs for the rest of the Calendar class (particularly the fields). See any that you think might help?
Fifth: Why are you using a TimeStamp? Were you told to? Calendars work best with Dates (java.util.Date).
Isn't it funny how there's always time and money enough to do it WRONG?
Rishal Dev Singh
Joined: Jun 18, 2012
i have done it using Calendar.HOUR_OF_DAY i had created a method name sayTime which is now working fine....
i was using TimeStamp because i m reffering a book named Just java 2 second edition and i was solving one of the exercises actually they have the examples using TimeStamp and i just adapted from there ...