【发布时间】:2013-03-18 13:06:42
【问题描述】:
我有一个计时器格式 (hh:mm:ss)。我喜欢有一个格式(mm:ss)(仅限分钟)。
例如:01:30:00 到 90:00。请帮帮我
【问题讨论】:
-
我没有使用 setFormat()。只是计时器的默认格式
我有一个计时器格式 (hh:mm:ss)。我喜欢有一个格式(mm:ss)(仅限分钟)。
例如:01:30:00 到 90:00。请帮帮我
【问题讨论】:
考虑这段代码:
/**
* Format of the time
*/
private final static String MINUTE_SECOND_FORMAT = "%02d:%02d";
///// code...
final int minutes = (currentSeconds % 3600) / 60;
final int seconds = currentSeconds % 60;
String formatted = String.format(Locale.getDefault(), MINUTE_SECOND_FORMAT, minutes, seconds);
这样你就可以得到一个格式化的字符串,格式为分:秒。
【讨论】: