【发布时间】:2013-02-06 06:24:22
【问题描述】:
我有这个代码:
class ClockLabel extends JLabel implements ActionListener {
public ClockLabel() {
super("" + new java.util.Date());
Timer t = new Timer(1000, this);
t.start();
}
@Override
public void actionPerformed(ActionEvent ae) {
txtclock.setText((new java.util.Date()).toString());
}
}
我的输出是
Wed Feb 06 14:22:44 CST 2013
如何以这种格式更改我的输出
"MM dd yyyy HH:mm:ss"
【问题讨论】:
-
我尝试输入 super("" + new java.util.Date("MM dd yyyy HH:mm:ss"));
-
谷歌搜索
java format date将SimpleDateFormat作为第一个链接。