Home arrow static arrow Java Programming [Archive] - time time time
Warning: Creating default object from empty value in /www/htdocs/w008deb8/wiki/components/com_staticxt/staticxt.php on line 51
Java Programming [Archive] - time time time
This topic has 6 replies on 1 page.

Posts:21
Registered: 11/17/03
time time time  
Aug 6, 2004 7:02 AM



 
Hi, im tryin to make a program that creates current time and US Time, to get US time id like to create a method called toUSTime(int CurrentTime) that receives the current time as an integer and returns the US time. i CAnt seem to get it workin at all. PLease help
Thanks

import java.awt.*;import java.util.*;import java.text.SimpleDateFormat;import java.applet.Applet;import javax.swing.*;import java.awt.event.*;  public class Clock extends JFrame implements Runnable { // variable declarationsprivate Thread clockThread = null;private boolean running;private SimpleDateFormat timeFormatter;private SimpleDateFormat UStimeFormatter;private JTextField addTimeTextField;private String clockText;private JLabel UKLabel, CurrentTime, USLabel,toUSTime ,ResultLabel, AddLabel; public Clock() { Container c = getContentPane();GridBagLayout gridbag = new GridBagLayout();GridBagConstraints constraints = new GridBagConstraints();    c.setLayout( gridbag);constraints.fill = GridBagConstraints.HORIZONTAL;    // create a formatter object which extracts// only time information from a Date objecttimeFormatter = new SimpleDateFormat("HH':'mm':'ss");UStimeFormatter = new SimpleDateFormat("HH':'mm':'ss");           UKLabel = new JLabel("UK Time");      constraints.gridx=0;      constraints.gridy=0;      constraints.weightx=1.0;// constraints.gridwidth = 3;      gridbag.setConstraints(UKLabel,constraints);      c.add( UKLabel );        CurrentTime = new JLabel(clockText);      constraints.gridx=1;      constraints.gridy=0;      constraints.weightx=1.0;// constraints.gridwidth = 3;      gridbag.setConstraints(CurrentTime,constraints);      c.add( CurrentTime );          USLabel = new JLabel("US Time");      constraints.gridx=0;      constraints.gridy=1;      constraints.weightx=1.0;// constraints.gridwidth = 3;      gridbag.setConstraints(USLabel,constraints);      c.add( USLabel );             toUSTime = new JLabel(clockText);      constraints.gridx=1;      constraints.gridy=1;      constraints.weightx=1.0;// constraints.gridwidth = 3;      gridbag.setConstraints(toUSTime,constraints);      c.add( toUSTime);          AddLabel = new JLabel("Add Time");      constraints.gridx=0;      constraints.gridy=2;      constraints.weightx=1.0;// constraints.gridwidth = 3;      gridbag.setConstraints(AddLabel,constraints);      c.add( AddLabel );          addTimeTextField = new JTextField(9);      constraints.gridx=1;      constraints.gridy=2;      constraints.weightx=1.0;// constraints.gridwidth = 3;      gridbag.setConstraints(addTimeTextField,constraints);      c.add( addTimeTextField );          ResultLabel = new JLabel("Any Time");      constraints.gridx=0;      constraints.gridy=3;      constraints.weightx=1.0;// constraints.gridwidth = 3;      gridbag.setConstraints(ResultLabel,constraints);      c.add( ResultLabel );          setSize( 300, 150 );      show();      start();}public void toUSTime(int CurrentTime){	} public void start() {// make a new thread objectif (clockThread == null) {// pass it this object and a nameclockThread = new Thread(this, "Clock");// start the threadclockThread.start();running = true;}} public void run() {// this method is called when the Thread manager// allows this thread some computing timewhile (running) { CurrentTime.setText( timeFormatter.format(new Date()));CurrentTime.repaint(); toUSTime.setText( UStimeFormatter.format(new Date()));toUSTime.repaint();    try {Thread.sleep(1000);}catch (InterruptedException e){ }}}    //public void paint(Graphics g) {// get a new time and format it into a text string//String clockText = timeFormatter.format(new Date());// and print it//g.drawString(clockText,30,69);  //}  	 public void stop() {running = false;clockThread = null;}   public static void main( String args[] )   {       Clock app = new Clock();       app.addWindowListener(         new WindowAdapter() {            public void windowClosing( WindowEvent e )            {               System.exit( 0 );            }         }      );}}
 

Posts:19,725
Registered: 9/26/01
Re: time time time  
Aug 6, 2004 7:15 AM (reply 1 of 6)



 
I think everyone's getting a little tired of your persistent attempts to get others to do your work for you.
http://forum.java.sun.com/thread.jsp?thread=543341&forum=31&message=2637298
 

Posts:14,142
Registered: 99-04-02
Re: time time time  
Aug 6, 2004 7:16 AM (reply 2 of 6)



 
What's US time? There are 6 time zones in the US.
 

Posts:24,036
Registered: 2/3/03
Re: time time time  
Aug 6, 2004 7:38 AM (reply 3 of 6)



 
Time, time, time, see what's become of me
While I looked around for my possibilities.
I was so hard to please.
but look around
Leaves are brown
And the sky is a hazy shade of winter.
 

Posts:14,142
Registered: 99-04-02
Re: time time time  
Aug 6, 2004 8:19 AM (reply 4 of 6)



 
And it's Time Time Time
And it's Time Time Time
And it's Time Time Time
that you love
And it's Time Time Time
 

Posts:668
Registered: 9/2/03
Re: time time time  
Aug 6, 2004 8:44 AM (reply 5 of 6)



 
Tiiii-iii-iii-ime, is on my side, yes it is!!
 

Posts:24,036
Registered: 2/3/03
Re: time time time  
Aug 6, 2004 8:49 AM (reply 6 of 6)



 
Shifting gears, but keeping it on the roadway....

I - I've been watching U
I think I wanna know ya (know ya)
Said I, I'm a little dangerous
Girl, I'd love 2 show ya (show ya)

My jungle love, yeah
I think I wanna know ya (know ya)
Jungle love
Girl, I'd love 2 show ya (show ya)
 
This topic has 6 replies on 1 page.