首页 > Timestamp类型的"2016-03-29 10:20:34.0"怎么去掉后面多余的.0.只要到秒

Timestamp类型的"2016-03-29 10:20:34.0"怎么去掉后面多余的.0.只要到秒

Timestamp类型的"2016-03-29 10:20:34.0" 有什么方法可以把后面的毫秒去掉吗??
只要"2016-03-29 10:20:34"

谢谢!!!


JSP页面的话,可以用标签格式化:

<fmt:formatDate value="${xxxxxx}" pattern="yyyy-MM-dd HH:mm:ss"/>

Java中可以将TimeStamp转为String类型,转换可以参考:

public String timeSplitMs(Timestamp ts) {
    DateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    try {
        if (null != ts) {
            return sdf.format(ts);
        }
    } catch (Exception e) {
        logger.warn("TimeStamp转换String格式出错", e);
    }
    return null;
}
【热门文章】
【热门文章】