• JAVA日期JSON格式转换


    Date.prototype.format = function(format) {
      /*
      * format="yyyy-MM-dd hh:mm:ss";
      */
      var o = {
      "M+" : this.getMonth() + 1,
      "d+" : this.getDate(),
      "h+" : this.getHours(),
      "m+" : this.getMinutes(),
      "s+" : this.getSeconds(),
      "q+" : Math.floor((this.getMonth() + 3) / 3),
      "S" : this.getMilliseconds()
      }
      if (/(y+)/.test(format)) {
      format = format.replace(RegExp.$1, (this.getFullYear() + "").substr(4- RegExp.$1.length));
      }
      for (var k in o) {
      if (new RegExp("(" + k + ")").test(format)){
      format = format.replace(RegExp.$1, RegExp.$1.length == 1? o[k]:("00" + o[k]).substr(("" + o[k]).length));
      }
      }
      return format;
    }
    
    
    function toDate(objDate,format){
    
      var date = new Date();
    
      date.setTime(objDate.time);
    
      date.setHours(objDate.hours);
    
      date.setMinutes(objDate.minutes);
    
      date.setSeconds(objDate.seconds);
    
      return date.format(format);
    
      }
    var newLine = "<br />";
    
    var re = /(w+)@(w+).(w+)/g
    var src = "Please send mail to george@contoso.com and someone@example.com. Thanks!"
    
    var result;
    var s = "";
    
    // Get the first match.
    result = re.exec(src);
    
    while (result != null) {
        // Show the entire match.
        s += newLine;
    
        // Show the match and submatches from the RegExp global object.
        s += "RegExp.lastMatch: " + RegExp.lastMatch + newLine;
        s += "RegExp.$1: " + RegExp.$1 + newLine;
        s += "RegExp.$2: " + RegExp.$2 + newLine;
        s += "RegExp.$3: " + RegExp.$3 + newLine;
    
        // Show the match and submatches from the array that is returned
        // by the exec method.
        for (var index = 0; index < result.length; index++) {
            s +=  index + ": ";
            s += result[index];
            s += newLine;
        }
    
        // Get the next match.
        result = re.exec(src);
    }
    document.write(s);
    
    // Output:
    //  RegExp.lastMatch: george@contoso.com
    //  RegExp.$1: george
    //  RegExp.$2: contoso
    //  RegExp.$3: com
    //  0: george@contoso.com
    //  1: george
    //  2: contoso
    //  3: com
    
    //  RegExp.lastMatch: someone@example.com
    //  RegExp.$1: someone
    //  RegExp.$2: example
    //  RegExp.$3: com
    //  0: someone@example.com
    //  1: someone
    //  2: example
    //  3: com
  • 相关阅读:
    php生成随机颜色代码
    终于完成了 源码 编译lnmp环境
    json_encode 中文 null
    push is not a function
    linux 搭建svn 服务器
    samba 挂载windows共享文件夹
    php 加密 解密 方法
    serialize unserialize
    CentOS Linux解决Device eth0 does not seem to be present 但是没有发现eth1
    javascript 获取视口的高度和宽度
  • 原文地址:https://www.cnblogs.com/wh-king/p/3147524.html
Copyright © 2020-2023  润新知