Package io.milton.common
Class Formatter
java.lang.Object
io.milton.common.Formatter
Handy functions exposes to rendering logic for formatting.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final ThreadLocal<DateFormat>static final ThreadLocal<DateFormat>static ThreadLocal<DateFormat>static ThreadLocal<DateFormat> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturn a date which has the given number of days added (or subtracted if negative) to the given datebooleanformatMinsAsDuration(Object o, boolean numeric) Given a value which can be parsed to a Long, return it formatted as a human readable duration such as 12:30 (12 mins, 30 seconds) or 12 mins, 3 hrs 20intintgetMonthName(int i) intbooleanTrue if val1 is greater then val2 will do string conversionsThis just permits simple templating syntax for basic conditional values Eg: $item.textbooleanGenerate an option elementpad(long l, int length) pad2(long l) Decode percentage encoded paths.sdf(boolean hasTime) Removes the file extension if present Eg file1.swf -> file1 file1 -> file1toBigDecimal(Object o, int decimals) Format as a percentage, including a percentage symbol and where blank/null values result in a blank outputtoSqlTimestamp(Object oVal) Null safe method, returns empty string if the value is null
-
Field Details
-
CHECKBOX_SUFFIX
- See Also:
-
tlSdfUkShort
-
tlSdfUkLong
-
sdfDateOnly
-
sdfDateAndTime
-
-
Constructor Details
-
Formatter
public Formatter()
-
-
Method Details
-
toString
Null safe method, returns empty string if the value is null- Parameters:
o-- Returns:
-
toBool
-
toDecimal
-
toDouble
-
toLong
-
toLong
-
getYear
-
getMonth
-
getDayOfMonth
-
formatMinsAsDuration
-
formatMinsAsDuration
Given a value which can be parsed to a Long, return it formatted as a human readable duration such as 12:30 (12 mins, 30 seconds) or 12 mins, 3 hrs 20- Parameters:
o-numeric-- Returns:
-
pad2
-
pad
-
padWith
-
toPercent
Format as a percentage, including a percentage symbol and where blank/null values result in a blank output- Parameters:
num- - the numeratordiv- - the divisor- Returns:
-
toPercent
- Parameters:
num-div-appendSymbol- - if true the percentage symbol is appended if a non-blank valuewithBlanks- - if true, blank numerators or divisors result in a blank value. Otherwise return zero.- Returns:
-
stripExt
Removes the file extension if present Eg file1.swf -> file1 file1 -> file1- Parameters:
s-- Returns:
-
gt
True if val1 is greater then val2 will do string conversions- Parameters:
val1-val2-- Returns:
-
lt
-
eq
-
percentDecode
Decode percentage encoded paths. Eg a%20b -> a b- Parameters:
s-- Returns:
-
percentEncode
-
toDate
-
toSqlDate
-
toSqlTimestamp
-
toPlain
-
getMonthName
-
ifEqual
-
ifTrue
This just permits simple templating syntax for basic conditional values Eg:- $item.text
- Parameters:
b-o1-o2-- Returns:
-
sdf
-
toBigDecimal
-
checkbox
-
checkbox
-
checkbox
-
radio
-
option
Generate an option element- Returns:
-
toCsv
-
toCsv
-
addDays
Return a date which has the given number of days added (or subtracted if negative) to the given date- Parameters:
now-i-- Returns:
-