Java display current time

前端 未结 6 1936
一向
一向 2021-01-02 02:05

I have a code which shows me the current date and time when I run my application

DateFormat dateFormat = new SimpleDateFormat(\"yyyy/MM/dd HH:mm:ss\");
Calen         


        
6条回答
  •  暖寄归人
    2021-01-02 03:08

        public void ShowTime() {
            new Timer(0, new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    Date d = new Date();
                    SimpleDateFormat s = new SimpleDateFormat("dd/MM/yyy hh:mm:ss a");
                    time.setText(s.format(d));                 //time= jlabel 
                }
            }).start();
        }
    

    Continuously Change time(refresh every second)

提交回复
热议问题