1. Formatted date
${updated?string ("Yyyy-mm-dd HH:mm:ss")}
If the specified variable does not necessarily exist, you can:
${(Datemap.begintime?string ("yyyy. MM.DD "))!
2. Display a Boolean value
< #assign foo=true/> ${foo?string ("Yes", "No")}
3. Intercept string length
<#if (uservo.cnname)?? && ((uservo.cnname) length > Ten) > ${uservo.cnnamesubstring (0,10)}.. <#Else> ${(uservo.cnname)! " } </#if >
4. Number format
Three number formats were booked in Freemarker: number,currency (currency) and percent (percent) where number is the default numeric format conversion
For example:
< #assign tempnum=20>${tempnum} ${tempnum? String.number} or ${tempnum? String ("number")} result is 20${tempnum? String.currency} or ${tempnum?string ("Currency")} result is ¥20.00 ${tempnum? string. Percent} or ${tempnum?string ("percent")} result is 2,000%
Freemarker number formatting can be set in two places, one is global, that is, setting Number_format in the Freemarker.properties file, and the other is to use the string instruction to control the output format of the data. For example:
${num?string (' 0.00 ')}
if less than two digits after the decimal point, replace with 0
${num?string (' #.## ')}
If the decimal point is more than two bits, only two bits are reserved, otherwise the output actual value output is: 1239765.46
${num?string (', ###.00 ')}
output is: 1,239,765.46
Integer part every three bits used, split, and guaranteed to retain two digits after the decimal point, less than 0 instead of
${num?string (', ###.## ')}
output is: 1,239,765.46
Integer part of every three bits with, split, and after the decimal point extra two bits will only retain two bits, less than two digits to take the actual number of digits, you can not include the decimal point
${num?string (' 000.00 ')}
output is: 012.70
If the integer part is less than three bits (000), the front is padded with 0, otherwise the actual integer digits are taken.
${num?string (' ###.00 ')} is equivalent to ${num? string (' #.00 ')}
output is: 12.70
Integer takes the actual number of digits
Freemarker all kinds of formatting