1
我想格式化上午/下午格式的分钟/小时的endTime。有问题的地区似乎在早上00.00 - 1.00和下午12.00 - 1.00之间。不知道这是正确的方法,还是有一种更简单的方法来实现这一点?如何格式化上午/下午格式的小时,分钟
public final String getEndTime() {
StringBuffer buf = new StringBuffer();
buf.append(this.getEndTimeInHrs() < 13 ? this.getEndTimeInHrs() : this
.getEndTimeInHrs() - 13).append(COLON);
// this check is needed to prefix an additional string in front of the
// minute (e.g. for 6 hrs 5 minutes, it will be displayed as 6:05)
if (this.getEndTimeInMinutes() < 10) {
buf.append(0);
}
buf.append(this.getEndTimeInMinutes());
if (getEndTimeInHrs() < 12) {
buf.append(SPACE).append(AM);
} else if (getEndTimeInHrs() > 12) {
buf.append(SPACE).append(PM);
}
return buf.toString();
}
没有一个日期作为输入,只需在小时/分钟时间 – user339108 2010-10-05 08:15:47
然后创建一个见。编辑。 – Joey 2010-10-05 08:18:06
使用日历而不是日期构造日期 – user339108 2010-10-05 08:23:48