jsp页面格式化时间
来源:互联网 发布:sql server 修改语句 编辑:程序博客网 时间:2024/05/21 17:22
jsp页面格式化时间
直接显示可以用<fmt:formatDate>标签,
需要导入<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
使用时<fmt:formatDate value="需要转化的时间" pattern="yyyy-MM-dd HH:mm:ss"></fmt:formatDate>
但是在ajax的回调函数中不能这样使用,但是可以使用js自己写格式化时间的函数
//格式化时间
Date.prototype.format = function(format) {
var o = {
"M+": this.getMonth() + 1, //month
"d+": this.getDate(), //day
"h+": this.getHours(), //hour
"m+": this.getMinutes(), //minute
"s+": this.getSeconds(), //second
"q+": Math.floor((this.getMonth() + 3) / 3), //quarter
"S": this.getMilliseconds() //millisecond
}
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;
}
使用时可以 var myTime=new Date(需要格式化的时间).format("yyyy-MM-dd hh:mm:ss")
直接显示可以用<fmt:formatDate>标签,
需要导入<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
使用时<fmt:formatDate value="需要转化的时间" pattern="yyyy-MM-dd HH:mm:ss"></fmt:formatDate>
但是在ajax的回调函数中不能这样使用,但是可以使用js自己写格式化时间的函数
//格式化时间
Date.prototype.format = function(format) {
var o = {
"M+": this.getMonth() + 1, //month
"d+": this.getDate(), //day
"h+": this.getHours(), //hour
"m+": this.getMinutes(), //minute
"s+": this.getSeconds(), //second
"q+": Math.floor((this.getMonth() + 3) / 3), //quarter
"S": this.getMilliseconds() //millisecond
}
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;
}
使用时可以 var myTime=new Date(需要格式化的时间).format("yyyy-MM-dd hh:mm:ss")
阅读全文
0 0
- jsp页面格式化时间
- jsp 页面时间格式化
- JSP页面格式化时间
- jsp页面格式化时间
- JSP页面时间类型格式化
- jsp页面格式化时间输出
- jsp页面标签时间格式化
- JSP 页面对时间格式化
- jsp:格式化页面时间显示格式
- jsp页面获取当前时间并格式化
- jsp页面格式化数字或时间
- jsp页面格式化数字或时间
- JSP页面使用JSTL fmt 格式化时间
- jsp页面格式化数字或时间
- jsp页面格式化数字或时间
- jsp页面格式化时间或数字
- jsp页面格式化数字或时间
- jsp页面格式化数字或时间
- 基于热点短信息分类的研究与实现-2008年硕士论文答辩PPT
- px4原生源码学习二--实时操作系统篇
- 怎样知道做到
- 解决Failed to load class "org.slf4j.impl.StaticLoggerBinder"
- 操作符重载
- jsp页面格式化时间
- Java NIO实现WebSocket服务器
- 常用的布局及技巧
- px4原生源码学习三--Nuttx实时操作系统的使用
- java基础杂谈(二)之 switch的多重匹配
- JQuery判断是否为空
- 当当网爬虫
- grokdebuggera安装配置
- HadoopRPC框架-----模拟NameNode和Client通信