就在我这个程序上面添加个什么方法 或者条件!! 就可以实现同时显示不同时区的时间!!!
import java.awt.*;
import java.awt.event.*;
import java.util.*;public class MyClock  implements Runnable{

Frame f;
Label time1;
Label time2;
Label time3;
Label time4;
Label time5;
Label time6; public MyClock(){
    f=new Frame("时刻表");
    time1=new Label("Asia/shanghai");
    time2=new Label("Europe/Moscow");
    time3=new Label("America/Los_Angeles");
    time4=new Label();
    time5=new Label();
    time6=new Label();
  
f.setLayout(new GridLayout(3,2));
f.add(time1);
f.add(time4);
f.add(time2);
f.add(time5);
f.add(time3);
    f.add(time6);
    
    
    f.pack();
f.setVisible(true);
       
        f.addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e){
 System.exit(0);

}

});
  
  time4.setFont(new Font("Arial", Font.PLAIN, 20));
  time5.setFont(new Font("Arial", Font.PLAIN, 20));
  time6.setFont(new Font("Arial", Font.PLAIN, 20));

  Thread  a=new Thread(this);       a.start();
  
     
 
       }
     
        public void run(){
         //System.out.println("111111111111111");
         while(true){
      try{
      //System.out.println("aaaaaaaaaaaaaaaaaa");
      Thread.sleep(1000);
time4.setText(getTime());
          time5.setText(getTime());
      time6.setText(getTime());      }
      catch(Exception e){
     
        e.printStackTrace();
      }
     
     
      }
     
     
      }
       private String getTime(){
      GregorianCalendar th=new GregorianCalendar();
        Calendar cal = new GregorianCalendar(TimeZone.getTimeZone("Europe/Moscow"));
       return th.get(GregorianCalendar.HOUR)+":"+
              th.get(GregorianCalendar.MINUTE)+":"+
              th.get(GregorianCalendar.SECOND);
     
           }
        
    
           
           
        public static TimeZone getDefault(){
          
           return TimeZone.getDefault();
      
       }      
        
        
        
        
   public static void main(String []args){
MyClock h=new MyClock();
    

}



解决方案 »

  1.   

    比如nowtime 是A地时间, B地和A地时差是两小时 那B地时间就是: new Date(nowtime.getTime()-2*60*60*1000);
      

  2.   

    哈哈,LZ的东西都写好了,就是差了一点。这个方法改成这样就行了。
        private String getTime(String timeZone) {
            GregorianCalendar th = new GregorianCalendar(TimeZone
                    .getTimeZone(timeZone));
            return th.get(GregorianCalendar.HOUR) + ":"
                    + th.get(GregorianCalendar.MINUTE) + ":"
                    + th.get(GregorianCalendar.SECOND);
        }
    之前是建好的cal实例没用啊。
      

  3.   

    getTime方法改完后,再把run方法改了。
        public void run() {
            while (true) {
                try {
                    Thread.sleep(1000);
                    time4.setText(getTime("Europe/Moscow"));
                    time5.setText(getTime("China/Shanghai"));
                    time6.setText(getTime("America/Los_Angeles"));
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }
      

  4.   

    快下班了,想到一句说一句,大家见谅:1: 第一个数小于8,则第二个数必须为正数,且只能有一位
    即String.length() == 12:第一个数大于8,第二个数必小于0,即第一位是"-";
    且first.length - (second.length-1) == 0
    且str.substring(0,first.length - 2)相同
    如first = 1234589 (len = 7)
     second =-1234581 (len = 7)
            12345相同
      first = 1234580
     second =-1234572
          12345 相同