thymeleaf中的日期格式化
本篇介绍些thymeleaf中的日期格式化的方法:
1.用#dates.format来解决:
<span th:text="${#dates.format(user.date, 'yyyy-MM-dd')}">4564546</span>
或者
<span th:text="${#dates.format(billingForm.startTime,'yyyy-MM-dd HH:mm:ss')}">4564546</span>
2.在当前的项目中还有这样一种情况,就是无法直接把需要thy表达式的放在标签里,因为他可能是在js里面拼接的。如下:
<script th:inline="javascript">
$(function (){
Date.prototype.Format = function (fmt) { //将蓝括号的这段要放在调用时间的上面,
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(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
for (var k in o)
if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
return fmt;
} $.each([[${cctwps}]], function (){
var course = this.course,
courseClass = this.courseClass,
time = '';
//班级别名,班级地址,开课时间,截止时间 if(course.applyEndDate != null){//报名中 截止报名时间
if(course.statusMark == 1){
time = '<span>'+
'<span>'+course.applyEndDate.substring(0,10)+'截止报名</span>'+
'</span>';
}else{
time = '<span>'+
'<span>'+new Date(course.startTime).Format("yyyy-MM-dd hh:mm")+'开课</span>'+
'</span>';
}
}else{
time = '';
} });
})
</script>
这里面course.startTime 就是你要拼接放进去的数据。
如果还有其它方法如果我找到了,会有后续更新。。。
thymeleaf中的日期格式化的更多相关文章
- JSON中的日期格式化
Json字符串中的日期格式化函数 ConvertJsonDate: function (jd) { var d = new Date(parseInt(jd.replace("/Date(& ...
- python中时间日期格式化符号
python中时间日期格式化符号: import time print(time.strftime('%Y%H%M%S', time.localtime())) 运行结果: 2016092308 %y ...
- Layui 模板引擎中的 日期格式化
原文:https://www.jianshu.com/p/948a474b5ed7 原文:https://blog.csdn.net/DCFANS/article/details/92064112 模 ...
- SQL Server中的日期格式化
SQL Server中文版的默认的日期字段datetime格式是yyyy-mm-dd Thh:mm:ss.mmm 例如: select getdate() 2004-09-12 11:06:08 ...
- JavaScript中对日期格式化的新想法.
其实我们对与日期的显示,也就那么几种,不需要每次都传格式化字符串. 只要告诉函数你想要什么结果就好了,以下是在ios的JavaScript中我新写的日期格式化函数: /** 格式化日期 @param ...
- Android开发中的日期格式化
下面的转换符来自Java,但是在android中同样可用.(以下表格内容来自互联网.) 常见日期格式化转换符 转换符 说 明 示 例 %te 一个月中的某一天(1-31) 2 %tb 指定语言环 ...
- springmvc中对日期格式化的处理
@DateTimeFormat(pattern="yyyy-MM-dd") 返回的时候java.util.Date pattern="yyyy-MM-dd"必须 ...
- JS中增加日期格式化原型函数之prototype
/** * javascript Date format(js日期格式化) * 对Date的扩展,将 Date 转化为指定格式的String 月(M).日(d).小时(h).分(m).秒(s).季度( ...
- thymeleaf中double/float格式化,四舍五入显示两位小数
private Float balance; 代码: <span class="A124_balance_num" th:text="${#numbers.form ...
随机推荐
- html模板中的数字保留两位小数
<script> //html模板中的数字保留两位小数 function formatCurrency(num) { num = num.toString().replace(/\$|\, ...
- java数组降序排序之冒泡排序
import java.util.Arrays;//必须加载 class Demo{ public static void main(String []args){ int[] arr={3,54,4 ...
- [leetcode-582-Kill Process]
Given n processes, each process has a unique PID (process id) and its PPID (parent process id). Each ...
- JS初步学习
[使用JS的三种方式] 1.HTML标签中内嵌JS(不提倡使用): <button onclick="javascript:alert('小碧池!你真点啊!')">有本 ...
- kbengine_js_plugins 在Cocos Creator中适配
kbengine_js_plugins 改动(2017/7/6) 由于Cocos Creator使用严格模式的js,而原本的kbengine_js_plugins是非严格模式的,因此为了兼容和方 便C ...
- CSS3学习系列之布局样式(一)
多栏布局 使用float属性或position属性的缺点: 使用float属性或position属性进行页面中的简单布局的例子. <!DOCTYPE html> <html lang ...
- 简单粗暴的在vmware虚拟机中固定ip
虚拟机对于很多做测试的或者在学习测试中的人来说是位常客,经常会用到,但是虚拟机重启之后,很多人遇到虚拟机ip变化,很是头痛,我在学习过程中也遇到了这个问题,百度了很多办法,有些办法对于网络知识小白来说 ...
- Watson Explorer Analytical Components 3 - use case scenarios
The followings are the user case scenarios that WEX can be used for generating value. 1.Customer Ins ...
- Django学习(一)---基本配置及创建项目、应用
安装:在Django官网下载最新版Django然后通过pip安装即可 一.创建项目 进入文件夹,打开cmd窗口,输入django-admin startproject myblog(项目名) 二.创建 ...
- Spring Security @PreAuthorize 拦截无效
1. 在使用spring security的时候使用注解,@PreAuthorize("hasAnyRole('ROLE_Admin')") 放在对方法的访问权限进行控制失效,其中 ...