如何阻止整數在時間內丟棄零?我試過格式化它截止日期下降爲零
String.format("%02d", minutes);
但它不工作,我敢肯定它很簡單!
Date dt = new Date();
int hours = dt.getHours();
int minutes = dt.getMinutes();
String curTime = hours + ":" + minutes;
String.format("%02d", minutes);
updatedat.setText("Updated at " + curTime);
爲什麼AREN你使用SimpleDateFormat嗎?當你不使用結果時,你期望什麼時候調用'String.format(「%02d」分鐘)? – 2013-04-25 15:12:40
哦,並且請注意'getHours'和'getMinutes'都被棄用的事實。你應該使用'日曆' - 或理想的喬達時間。 – 2013-04-25 15:13:49