基本参数:

  • date: 只显示日期,不显示时间.
    ${createTime?date}${createTime?date('yyyy-MM-dd')}
  • time: 只显示时间,不显示日期
    ${createTime?time}${createTime?time('hh:mm:ss')}
  • datetime: 时间和日期同时显示
    ${createTime}${createTime?datetime('yyyy-MM-dd hh:mm:ss')}${createTime?string('yyyy-MM-dd hh:mm:ss')}

Freemarker预置了一些日期格式

${createTime?string.short}  01:45 PM
${createTime?string.medium} 01:45:09 PM
${createTime?string.long} 01:45:09 PM PST
${createTime?string.full} 01:45:09 PM PST
${createTime?string.xs} 13:45:09-08:00
${createTime?string.iso} 13:45:09-08:00

字符串类型:

日期格式:${book.date?string('yyyy-MM-dd')}

文/Devid(简书作者)
原文链接:http://www.jianshu.com/p/980aaeea3402
著作权归作者所有,转载请联系作者获得授权,并标注“简书作者”。

Freemarker日期格式化处理的更多相关文章

  1. Freemarker 各种格式化

    1.格式化日期 ${updated?string("yyyy-MM-dd HH:mm:ss")} 如果指定的变量不一定存在,可以这样: ${(dateMap.beginTime?s ...

  2. springmvc日期格式化

    jsp页面String类型转Controller后台Date类型 方法1.在实体中加入日期格式化注解 @DateTimeFormat(pattern="yyyy-MM-dd") p ...

  3. C# DateTime日期格式化

    在C#中DateTime是一个包含日期.时间的类型,此类型通过ToString()转换为字符串时,可根据传入给Tostring()的参数转换为多种字符串格式. 目录 1. 分类 2. 制式类型 3. ...

  4. Json.net日期格式化

    1. 全局设置,可以在App_Global中配置 JsonSerializerSettings setting = new JsonSerializerSettings(); JsonConvert. ...

  5. 分享自己写的JS版日期格式化和解析工具类,绝对好用!

    前言 本来想模仿Java里面的SimpleDateFormat()对象的,但是感觉这样用起来不方便,所以还是直接写成单独的方法算了. 原文链接 日期格式化 使用说明 formatDate(date, ...

  6. Oracle 英文 非标准格式 日期 格式化

    最近在处理一张表的时候,需要按照日期排序,日期字段中日期的格式有两种. 格式一:07-Aug-2015 格式二:10/28/16 日期转化及格式化sql语句: select to_date('07-A ...

  7. Sql Server 日期格式化函数

    Sql Server 中一个非常强大的日期格式化函数Select CONVERT(varchar(100), GETDATE(), 0): 05 16 2006 10:57AMSelect CONVE ...

  8. django 过滤器、日日期格式化参数

    转载:http://blog.csdn.net/xyp84/article/details/7945094 django1.4 html页面从数据库中读出DateTimeField字段时,显示的时间格 ...

  9. 161226、js日期格式化

    JavaScript Date format(js日期格式化) 方法一:// 对Date的扩展,将 Date 转化为指定格式的String // 月(M).日(d).小时(h).分(m).秒(s).季 ...

随机推荐

  1. Direct2D相关

    1,如何绘制文本 2,文本格式设置和布局

  2. nginx重启

    ps aux | grep nginx 查找 主进程 号 kill 9666 /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.co ...

  3. 纯js异步无刷新请求(只支持IE)

    纯js异步无刷新请求 下载地址:http://pan.baidu.com/s/1slakL1F 所以因为非IE浏览器都禁止跨域请求,所以以只支持IE. <HTML> <!-- 乱码( ...

  4. 【接口测试】jmeter的使用

    学习地址: https://ke.qq.com/webcourse/index.html#course_id=89002&term_id=100088372&taid=15345918 ...

  5. 开启gpu加速的高性能移动端相框组件!

    通过设置新的css3新属性translateX来代替传统的绝对定位改变left值的动画原理,新属性translateX会开启浏览器自带的gpu硬件加速动画性能,提高流畅度从而提高用户体验, 代码有很详 ...

  6. 网站fail_over测试(障害测试)

    确认Web和DB进行操作: 一:确认web: ①确认进程是否存在: ps aux|grep tomcat ②关闭tomcat: /etc/init.d/catalina_sbi stop ③重启tom ...

  7. ELK:kibana使用的lucene查询语法【转载】

    kibana在ELK阵营中用来查询展示数据 elasticsearch构建在Lucene之上,过滤器语法和Lucene相同 全文搜索 在搜索栏输入login,会返回所有字段值中包含login的文档 使 ...

  8. clob型不能用 distinct,以及转换clob类型方法

    举例clob型不能用 distinct public List<WorkingPaper> findAssignedWorkPapers(String projectId, String ...

  9. 一个MVC架构的线程安全的银行转账案例(事务控制)

    mvc结构: 准备阶段:jar包 ,dbcpconfig.propertie(数据源配置文件 ) ,DBCPUtil. jar包: dbcp配置文件: driverClassName=com.mysq ...

  10. agsXMPP参考代码

    agsXMPP 1.删除好友 XmppCon.RosterManager.RemoveRosterItem(node.RosterItem.Jid); 2.注销用户 void userConn_OnL ...