Formatting database date datetime type, the date of

datetime database (time stamp) type is obtained Timestamp data type in java

Conversion code:

Timestamp TimestampCreateTime = (Timestamp) map.get("createTime");
//将timestamp类型的日期转换为java.sql.Date类型的
Date date = new Date(TimestampCreateTime.getTime());
SimpleDateFormat dateFormat=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String fCreateTime = dateFormat.format(date);
List<Map> cameraInfo=floorlaryservice.queryCameraSome(pId,fName, lName, rName, aName,cTime);
        for (Map map : cameraInfo) {
            Timestamp TimestampCreateTime = (Timestamp) map.get("createTime");
            //将timestamp类型的日期转换为java.sql.Date类型的
            Date date = new Date(TimestampCreateTime.getTime());
            SimpleDateFormat dateFormat=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            String fCreateTime = dateFormat.format(date);
            map.put("createTime",fCreateTime);
        }
        return cameraInfo;

When the map is createTime format, I should return cameraInfo, if we return

floorlaryservice.queryCameraSome (pId, fName, lName, rName, aName, cTime); did not return after the date type format

Guess you like

Origin www.cnblogs.com/Jane-he/p/11826383.html