中级农民
- 积分
- 108
- 大米
- 颗
- 鳄梨
- 个
- 水井
- 尺
- 蓝莓
- 颗
- 萝卜
- 根
- 小米
- 粒
- 学分
- 个
- 注册时间
- 2015-10-7
- 最后登录
- 1970-1-1
|
java也有对应的将这个时间换成原题,不过还是强烈谴责这波操作;
```
public void time(String time) throws ParseException {
String[] strs = time.split(" - ");
SimpleDateFormat format = new SimpleDateFormat("hh:mm a");
SimpleDateFormat date24Format = new SimpleDateFormat("HH:mm");
String start = date24Format.format(format.parse(strs[0]));
String end = date24Format.format(format.parse(strs[1]));
int startT = Integer.parseInt(start.substring(0, 2) + start.substring(3));
int endT = Integer.parseInt(end.substring(0, 2) + end.substring(3));
System.out.println("[ "+startT + ","+ endT + " ]");
}
```
跟他约定好时间格式 一定是 TT:TT xm - TT:TT ym 这样的。(x,y 可以是a跟b)
test.time("10:00 am - 10:20 am");
test.time("12:00 am - 12:00 pm");
test.time("12:30 pm - 1:00 pm"); |
|