java - Timestamp类型的"2016-03-29 10:20:34.0"怎么去掉后面多余的.0.只要到秒
PHPz
PHPz 2017-04-18 09:40:08
0
1
390

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

谢谢!!!

PHPz
PHPz

学习是最好的投资!

reply all(1)
PHPzhong

For JSP pages, you can use tags to format them:

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

TimeStamp can be converted to String type in Java. For conversion, please refer to:

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;
}
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template