1、后台处理方式:
/* 精简版解析 - 推荐 */
String a= "Fri Dec 11 00:00:00 CST 2015";
Date d = new Date(a);
String f = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(d);
System.out.println(f);
/* 稍繁版解析 */
import
java.text.ParseException;
import
java.text.SimpleDateFormat;
import
java.util.Date;
import
java.util.Locale;
public
class
Test {
public
static
void
main(String[] args) {
String str =
"Mon Dec 31 00:00:00 CST 2012"
;
Date date = parse(str,
"EEE MMM dd HH:mm:ss zzz yyyy"
, Locale.US);
System.out.printf(
"%tF %<tT%n"
, date);
}
public
static
Date parse(String str, String pattern, Locale locale) {
if
(str ==
null
|| pattern ==
null
) {
return
null
;
}
try
{
return
new
SimpleDateFormat(pattern, locale).parse(str);
}
catch
(ParseException e) {
e.printStackTrace();
}
return
null
;
}
}
2、前端js解析:
/* 精简版 - 推荐,其他版本就无视吧 O(∩_∩)O哈哈~ */
var d = new Date(‘Fri Dec 11 00:00:00 CST 2015‘);
var dateStr = d.getFullYear() + ‘-‘ + (d.getMonth() + 1) + ‘-‘ + d.getDate() + ‘ ‘
+ d.getHours() + ‘:‘ + d.getMinutes() + ‘:‘ + d.getSeconds();