我需要在我的申请表中显示经过的时间。
我目前使用以下代码执行此操作:
AppTimer = new Timer();
AppTimer.scheduleAtFixedRate(new java.util.TimerTask() {
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");
public void run() {
sdf.setTimeZone(java.util.TimeZone.getTimeZone("GMT+0"));
lblAppRunTime.setText(""+sdf.format(new Date(AppTimeCounter*1000)));
AppTimeCounter++;
}
},1000, 1000);
此代码正确显示小时、分钟和秒,但我如何显示 DAYS 和 MONTHS?
new SimpleDateFormat("M D HH:mm:ss")
不能这样做,例如当 5 秒过去时,它也显示 1 个月和 1 天!
我怎样才能显示月份和日期?
谢谢