zoukankan      html  css  js  c++  java
  • 把格式日期转换成毫秒

      /**
         *  把"yyyy-MM-dd HH:mm:ss"格式日期转换成毫秒
         *@param strDate
         *@return 转换后毫秒的值
         *@author hongj
         */
        public long paseDateTomillise(String strDate){
            String year = null;
            String month = null;
            String day = "";
            String hms = "";
            if(strDate.contains(" ") && !strDate.endsWith(" ")){
                String[] s = strDate.split(" ");
                hms = s[1];
            }
            String[] getYear = strDate.split("-");
            year = getYear[0].substring(2, 4);
            month = getYear[1];
            if("1".equalsIgnoreCase(month) || "01".equalsIgnoreCase(month)){
                month = "JAN";
            }else if("2".equalsIgnoreCase(month) || "02".equalsIgnoreCase(month)){
                month = "FEB";
            }else if("3".equalsIgnoreCase(month) || "03".equalsIgnoreCase(month)){
                month = "MAR";
            }else if("4".equalsIgnoreCase(month) || "04".equalsIgnoreCase(month)){
                month = "APR";
            }else if("5".equalsIgnoreCase(month) || "05".equalsIgnoreCase(month)){
                month = "MAY";
            }else if("6".equalsIgnoreCase(month) || "06".equalsIgnoreCase(month)){
                month = "JUN";
            }else if("7".equalsIgnoreCase(month) || "07".equalsIgnoreCase(month)){
                month = "JUL";
            }else if("8".equalsIgnoreCase(month) || "08".equalsIgnoreCase(month)){
                month = "AUG";
            }else if("9".equalsIgnoreCase(month) || "09".equalsIgnoreCase(month)){
                month = "SEPT";
            }else if("10".equalsIgnoreCase(month)){
                month = "OCT";
            }else if("11".equalsIgnoreCase(month)){
                month = "NOV";
            }else if("12".equalsIgnoreCase(month)){
                month = "DEC";
            }
            if(getYear[2].contains(" ")){
                day = getYear[2].split(" ")[0];
            }else{
                day = getYear[2];
            }
            String datees = day+"-"+month+"-"+year+" "+hms;
            Date datee = new Date(datees);
            return datee.getTime();
        }
  • 相关阅读:
    获取滚动条卷入高度以及获取内联和外联的方法
    async
    使一个div元素上下左右居中
    .NetCore/ .NetFramework 机制
    Asp.netCore 是用的Socket 吗?
    Asp.netCore 的Startup 不继承接口
    月球
    JWT
    虚数的作用
    C# mailKit 发邮件 简单代码
  • 原文地址:https://www.cnblogs.com/jh5240/p/2676888.html
Copyright © 2011-2022 走看看