在写程序的时候,不小心写了下面的
Java代码
public static final DateFormat formatWithTime = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
java.util.Date newStartTime = formatWithTime.parse("2009-09-09 13:41:00");
//把字符串转变成Date,发现总是转化成12小时制的,
//后来查资料发现,hh表示的是12小时制,HH才是24小时制
String startTimeStr = formatWithTime.format(scheduler.getStartTime());
把 formatWithTime改成下面的就可以了(hh变成HH)
Java代码
public static final DateFormat formatWithTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
下附,java.util.Date 24小时格式
字母 | 日期或时间元素 | 表示 | 示例 |
| Era 标志符 | Text |
|
| 年 | Year | |
| 年中的月份 | Month | |
| 年中的周数 | Number |
|
| 月份中的周数 | Number |
|
| 年中的天数 | Number |
|
| 月份中的天数 | Number |
|
| 月份中的星期 | Number |
|
| 星期中的天数 | Text | |
| Am/pm 标记 | Text |
|
| 一天中的小时数(0-23) | Number |
|
| 一天中的小时数(1-24) | Number |
|
| am/pm 中的小时数(0-11) | Number |
|
| am/pm 中的小时数(1-12) | Number |
|
| 小时中的分钟数 | Number |
|
| 分钟中的秒数 | Number |
|
| 毫秒数 | Number |
|
| 时区 | General time zone | |
| 时区 | RFC 822 time zone |
|