【发布时间】:2016-10-25 10:05:55
【问题描述】:
得到响应
"pickTime": "Tue Oct 25 03:57 PM"
我已经编码如下。
SimpleDateFormat curFormater = new SimpleDateFormat("E MMM dd hh:mm a");
SimpleDateFormat dateFormater = new SimpleDateFormat("E MMM dd");
SimpleDateFormat timeFormater = new SimpleDateFormat("hh:mm a");
String time = jsonObj.optString("pickTime");
Date dateObj = curFormater.parse(time);
String newDateStr = dateFormater.format(dateObj);
String newTimeStr = timeFormater.format(dateObj);
问题是我在 String time 中得到相同的值,但在 dateobj 中我得到的值是
"sun oct 25 15.57 pm"
newDatestr 为
"sun oct 25"
请帮我解决这个问题,提前谢谢
【问题讨论】:
-
您的
pickTime值将受益于一年。另外,请检查您设备的日期:10 月 25 日的最后一个星期日是 2015 年。 -
我不会收到一年的回复,那我该怎么办呢?正如你所说,我知道没有年份,默认为 1970,我正确吗?
-
pickTime += " " + currentYear,将其添加到SimpleDateFormat模式中。 -
简单解释一下,我要做什么
-
@Daryl:您必须定义如何确定年份。这是关于业务需求的。