请问如何在swing中加入显示系统时间的部分,麻烦大家看看,谢谢了

解决方案 »

  1.   

    date,time,clendar不知道你要哪个?
      

  2.   

    SimpleDateFormat sDateFormat = new SimpleDateFormat("yyyyMMddHHmmssMM");
          Date MyDate = new Date(System.currentTimeMillis()); //取系统时间
          String time = sDateFormat.format(MyDate);你想用什么控件显示啊?
    现在这个  time  就是时间了
    想怎么显示你看你需要了
      

  3.   

    Date MyDate = new Date(Calendar.getInstance().getTime()); //取系统时间
    如果生命MyDate改成这样也可以
    楼住可以自己看看有什么不同
      

  4.   

    timer = new Timer(true); 
            timer.schedule(new java.util.TimerTask() { 
                public void run() { 
                        //server.checkNewMail(); 检查新邮件 
                } 
            }, 0, 5*60*1000); //5*60*1000代表5分钟
      

  5.   

    SimpleDateFormat sDateFormat = new SimpleDateFormat("yyyyMMddHHmmssMM");这个为什么显示不出系统时间,显示的结果却是java.text.SimpleDateFormat@dd590b00?
    请问是怎么回事?
      

  6.   

    private class CurrentTime extends Thread {
            public void run(){
                while(Matrix.property.programRun){
                    try {
                        sleep(1000);
                    } catch (InterruptedException ex) {
                        ex.printStackTrace();
                    }
                    updateDateTime();
                }
            }
            
            /** 读取系统时间并回显 */
            private void updateDateTime(){
                Calendar cur = Calendar.getInstance();
                String date = String.format("%1$tF",cur);
                curDateTf.setText(date);
                String time = String.format("%1$tT",cur);
                curTimeTf.setText(time);
            }
        }