SimpleDateFormat sDateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
String date = sDateFormat.format(new java.util.Date());

解决方案 »

  1.   

    SimpleDateFormat formatter = new SimpleDateFormat ("yyyy.MM.dd HH:mm");
    formatter.format(new Date());
      

  2.   

    上述的date应该是英文格式,应该发展一个class专门显示中文格式。
      

  3.   

    df=DateFormat.getDateTimeInstance(DateFormat.FULL,DateFormat.FULL,Locale.CHINA);
    System.out.println(df.format(new Date()));
      

  4.   

    import java.text.SimpleDateFormat;SimpleDateFormat formatter = new SimpleDateFormat ("yyyy年MM月dd日 HH:mm:ss  ");Date curDate = new Date(System.currentTimeMillis());//获取当前时间
    String str = formatter.format(curDate);这样只是一个静止的时间,如果你想让程序中的这个显示时间时可表示当前的时间.
    应该利用一个线程或者直接用一个时钟.并且时钟的时间及设置为1s,每1秒刷新一次显示.
    比如:
    ActionListener listener = new ActionListener{
      public void actionPerformed(ActionEvent e){
            
            ***.setText("系统当前时间:" +formatter.format(new Date
                            (System.currentTimeMillis()))
                        );
            //***表示你在某个组件中显示出来这些信息.
        }
    }
    javax.swing.Timer oneSecondTimer = new javax.swing.Timer(1000,listener);
    oneSecondTimer.start();