private void Update() {
SimpleDateFormat sm = new SimpleDateFormat("yyyy年MM月dd HH:mm:ss");
label_time.setText(sm.format(new Date()));
label_time.setForeground(Color.magenta);
} private void Start() {
Thread t = new Thread() {
public void run() {
while (true) {
Update(); try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
};
t.start();
}说明程序没什么问题,能运行我想问的是现在每秒 new 一次 SimpleDateFormat这样会不会浪费资源