当在开发过程中,如果数据库(这里使用的是Mysql)数据库时,在获取当前时间时,中间带有“T”,去掉“T”,并进行了襄阳的方法封装。
public String getTime(CommunityTopics communiityTopics) {
String time = communiityTopics.getLastPostTime();
String[] splite = time.split("T");
String[] date = splite[1].split(":");
String[] month = splite[0].split("-");
String realTime = month[1] + "-" + month[2] + " " + date[0] + ":" + date[1];
return realTime;
}