Home Tutorialhelp Comment Have a problem?

 
 

Comment

Emeka Nwankwo
Have a problem?,
November 30, 2008 at 2:34 AM

This code i have learnt and applied in my project but its nt getting the system time. When i run it ordinary it got the sys time but when i applied it on a gui it didnt work.
This is a thread.

public void dateTime()
{
datetimeThread = new Thread(this);

datetimeThread.start();
}

public void run()
{
while(datetimeThread != null)
{
display();
try
{
datetimeThread.sleep(1000);
}
catch(InterruptedException e)
{
showStatus("Thread interrupted");
}
}
}

public void display()
{
date = new Date();
calendar = new GregorianCalendar();
calendar.setTime(date);
String am_pm;
int hour = calendar.get(Calendar.HOUR);
int minute = calendar.get(Calendar.MINUTE);
int second = calendar.get(Calendar.SECOND);
if (calendar.get(Calendar.AM_PM) == 0)
{
am_pm = "AM";
}
else
{
am_pm = "PM";
}
strTime = ("Current Time : " + hour + ":" + minute + ":" + second + " " + am_pm);
strDate = (calendar.get(Calendar.MONTH)+1)+"/"+calendar.get(Calendar.DATE)+"/"+calendar.get(Calendar.YEAR);
strStatus=strTime+" "+"Current Date " + strDate;
showStatus(strStatus);
}
View All Comments | View Tutorial
Advertisement
Related Tutorial and Articles
Java-Tutorials

Java Util Examples List
 

Java-Tutorials

Lang and Util Base Libraries
 

Java Beginners

util packages in java
 

Java-Tutorials

Java util package Examples
 

Java-Tutorials

Java Util Package - Utility Package of Java
 

Java Beginners

Java Util Zip. Zip files/folders inside a folder, without zipping the original source folder.
 

Java Beginners

java util date - Time Zone throwing illegal argument exception
 

Java Beginners

util
 

Core Java

Java util date
 

Java-Tutorials

Associate a value with an object
 

Programming Tutorials

Java hasNext
 

Java Beginners

In Java I have append to an existing string efficiently
 

Struts Questions

Still have the same problem--First Example of Struts2 - Struts
 

General

JavaScript add namespace
 

Java Beginners

FTP Java example
 

Java Beginners

Need to have a Java Code - Java Beginners
 

Swing AWT

in my project, i have to add scrollbars to a panel,. i need some example on it,how to doit.
 

Java Server Faces Questions

which tag i have to use - Java Server Faces Questions
 

Java Beginners

java string comparison example
 

Java Beginners

throws example program java
 

Java Beginners

Java File Management Example
 

Java Beginners

Java Queue Example
 

Java Beginners

Java collection Queue Example
 

Java Beginners

Java Map Example
 

Java Technology Tutorials

Java FileInputStream Example
 

General

Java: Example - ColorDisplay
 

Java Beginners

example explanation - Java Beginners
 

Java Beginners

i have no programming knowledge is it possible for study java?
 

Java Beginners

Java ArrayList Example
 

General

Getting Previous, Current and Next Day Date
 

Java Beginners

array example - Java Beginners
 

Java Technology Tutorials

Java Example Codes and Tutorials
 

Java Beginners

Java FTP file upload example
 

Java Beginners

StringReverse Example - Java Beginners
 

Java Beginners

java-jar file creation - Java Beginners
 

Struts Questions

Java Example projects about STRUTS
 

Java Beginners

does any one have sudoku in java - Java Beginners
 

Java Beginners

java - Java Beginners
 

Core Java

Inheritance Example In Java
 

Applet Questions

java - Applet
 

General

Java Pass Value Example
 

Java Beginners

Hello Sir I Have problem with My Java Project - Java Beginners
 

Java-Tutorials

First Java Program Example
 

Ajax Questions

java persistence example
 

Java Beginners

stack and queue - Java Beginners
 

Java Interview Questions

STACK&QUEUE - Java Interview Questions
 

Java Interview Questions

Java - Java Interview Questions
 

JavaMail Questions

i have problem in that program - JavaMail
 

Java Beginners

Java Client Application example
 

JSON

JSON and Servlet example
 

Java Beginners

java
 

Java Beginners

Java Syntax - Java Beginners
 

Programming Tutorials

Java: Example - Drawing a Face - v3
 

Core Java

Example of HashMap class in java
 

Core Java

Java Stack Example
 

Programming Tutorials

ajax example
 

Core Java

Example of HashSet class in java
 

Framework Questions

is it necessary to have depth knowledge on servlets jsp and jdbc to learn java frameworks
 

Java Beginners

java - Java Beginners
 

Java Beginners

java program example - Java Beginners
 

General

Java HashMap iterator and example
 

General

Java Collection iterator with example
 

JSON

JSONObject example in Java
 

Java Beginners

Java FTP Client Example
 

Core Java

Method Overloading Example In Java
 

Java Beginners

Sample Code For ArrayLlist - Java Beginners
 

Blog

Java Args example
 

Java-Tutorials

Java JdbcRowSet Example
 

Java-Tutorials

Java Word Occurrence Example
 

Core Java

Thread Life Cycle Example in java
 

Java Beginners

java - Java Beginners
 

JavaMail Questions

i have problem in that program sir - JavaMail
 

General

Java Time Zone Example
 

Java-Tutorials

Iterator in Java Example
 

JDK 6 Tutorials

Java set example
 

Java Beginners

Java FTP Example
 

JSP Tutorials

Java bean example in JSP
 

General

Site Map - All java tutorials
 

Java Interview Questions

java - Java Interview Questions
 

Java Beginners

looking to have the abilty to send boardcast alerts
 

Java Beginners

java
 

Java Beginners

java
 

Java Beginners

java
 

Java Beginners

java
 

Java Beginners

java
 

Java Beginners

java
 

General

Java example to get the execution path
 

Java-Tutorials

Constructor Overloading in Java
 

General

Java divide method example
 

Java Beginners

java
 

Java Beginners

java
 

Java Beginners

java
 

Java Beginners

java
 

Java Beginners

freemarker example - Java Beginners
 

Java-Tutorials

JAVA7 : "Hello World" Example
 

Java Beginners

printing example - Java Beginners
 

JDBC-Tutorials

Java Mysql Connection Example
 

JRuby

"TreeSet" example in JRuby
 

General

Adding time span example
 

Java Beginners

how to do combinations in java - Java Beginners
 

Advertisements Advertisements
 

 

 

DMCA.com