d0 = "2018-01-01 00:00:00";
SimpleDateFormat formate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");Date d1 = (Date) formate.parseObject(d0);String result = DateUtils.formatDate(d1, "yyyy-MM-dd hh:mm:ss");
System.out.println(result);为什么返回的是2017-12-31 04:00:00???补充:DateUtils.formatDate是\apache\httpcomponents\httpclient\4.5.1\httpclient-4.5.1.jar里面的方法:public static String formatDate(Date date, String pattern) {
Args.notNull(date, "Date");
Args.notNull(pattern, "Pattern");
SimpleDateFormat formatter = DateUtils.DateFormatHolder.formatFor(pattern); return formatter.format(date);
}
添加回答
举报
0/150
提交
取消