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;
             }
         }
    
  • 相关阅读:
    SpringBoot介绍
    linux运行jar以及vi
    linux文件命名
    数据库 mysql
    SSM框架-Spring
    SSM框架-mybatis
    SSM框架-SpringMVC
    设计模式-策略模式
    设计模式-单例模式
    Java多线程实现和JUC介绍
  • 原文地址:https://www.cnblogs.com/gloria-liu/p/9392097.html
Copyright © 2011-2022 走看看