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);
Why 2017-12-31 04:00:00
?
add:
DateUtils.formatDate
Yes
\apache\httpcomponents\httpclient\4.5.1\httpclient-4.5.1.jar
The method in :
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);
}