• [转]freemaker格式化日期


    转至:http://wentao365.iteye.com/blog/2047234

    1、格式化日期

    Java代码  收藏代码
    1. ${updated?string("yyyy-MM-dd HH:mm:ss")}  


    如果指定的变量不一定存在,可以这样:

    Java代码  收藏代码
    1. ${(dateMap.beginTime?string("yyyy.MM.dd"))!''}  


    2、显示boolean值

    Java代码  收藏代码
    1. <#assign foo=true/>  
    2. ${foo?string("yes", "no")}  


    3、截取字符串长度

    Java代码  收藏代码
    1. <#if (userVO.cnname)?? && ((userVO.cnname)?length > 10) >  
    2. ${userVO.cnname?substring(0,10)}..   
    3. <#else>  
    4. ${(userVO.cnname)!''}  
    5. </#if>  



    4、数字格式
    Freemarker中预订义了三种数字格式:number,currency(货币)和percent(百分比)其中number为默认的数字格式转换
    例如:

    Java代码  收藏代码
      1. <#assign tempNum=20>  
      2. ${tempNum}      
      3. ${tempNum?string.number}或${tempNum?string(“number”)}  结果为20  
      4. ${tempNum?string.currency}或${tempNum?string(“currency”)}  结果为¥20.00  
      5. ${tempNum?string. percent}或${tempNum?string(“percent”)}  结果为2,000% 

     

  • 相关阅读:
    CTF SQL注入知识点
    Rot13加密算法
    LFU缓存
    Redability
    快排
    更新卡片的zIndex
    webshell文件下载器
    [转]背包九讲
    hihocoder第196周
    Python import容易犯的一个错误
  • 原文地址:https://www.cnblogs.com/luoxiaolei/p/5121504.html
Copyright © 2020-2023  润新知