Mybatis springMVC page date format is displayed in English

The visitTime attribute of POJO is date, and the date value in mybatis is 2015-01-09. When mapped to POJO, it will become the English date format.

There is a problem with the display of the page.

Sat Apr 28 00:00:00 CST 2018


1. Solve from the database:
DATE_FORMAT(
visit_time,
'%Y-%m-%d'
) AS visit_time

Still displayed in English.

2 Convert the date of pojo to string. Write a conversion method directly in POJO.


public String formateTime(Date date) {
    SimpleDateFormat df=new SimpleDateFormat("yyyy-MM-dd");
    return df.format(date);

    }

Call it directly in EL:

${visit.formateTime(visit.visitTime) }



Sat Apr 28 00:00:00 CST 2018

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325649066&siteId=291194637