zoukankan      html  css  js  c++  java
  • 时间戳转换

    
    1  通过java,如下:
    
    ```java
       public static String timeStamp2Date(String time) {
        Long timeLong = Long.parseLong(time);
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//要转换的时间格式
        Date date;
        try {
            date = sdf.parse(sdf.format(timeLong));
            return sdf.format(date);
        } catch (ParseException e) {
            e.printStackTrace();
            return null;
        }
    }   
    
    
    

    2 js中转换,利用bootstraptable 加载,写一个方法返回

    
    
    
     columns: [
    		     {   title: "开盘时间",
    		        field: "openTime",
    		        formatter: function (value, row, index) {
    		            return changeDateFormat(value)
    		        }
    
    
    
    function changeDateFormat(cellval) {
             var dateVal = cellval + "";
             if (cellval != null) {
                 var date = new Date(parseInt(dateVal.replace("/Date(", "").replace(")/", ""), 10));
                 var month = date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1;
                 var currentDate = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
                 
                 var hours = date.getHours() < 10 ? "0" + date.getHours() : date.getHours();
                 var minutes = date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes();
                 var seconds = date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds();
                 
                 return date.getFullYear() + "-" + month + "-" + currentDate + " " + hours + ":" + minutes + ":" + seconds;
             }
         }
    
  • 相关阅读:
    190. Reverse Bits
    150. Evaluate Reverse Polish Notation
    【UML】状态图与活动图
    【UML】类图与对象图
    【UML】用例图
    【运维】Dell R710如何开启VT服务
    【运维】Dell R710如何做Raid0与Raid5
    【运维】略谈Raid级别
    【VMware vSphere】VMware vSphere简单了解
    【Linux】在Linux上安装VNC
  • 原文地址:https://www.cnblogs.com/gloria-liu/p/9392097.html
Copyright © 2011-2022 走看看