Class Formatter


  • public class Formatter
    extends Object
    Handy functions exposes to rendering logic for formatting.
    • Constructor Detail

      • Formatter

        public Formatter()
    • Method Detail

      • toString

        public String toString​(Object o)
        Null safe method, returns empty string if the value is null
        Parameters:
        o -
        Returns:
      • toLong

        public Long toLong​(Object oVal,
                           boolean withNulls)
      • getYear

        public int getYear​(Object o)
      • getMonth

        public int getMonth​(Object o)
      • getDayOfMonth

        public int getDayOfMonth​(Object o)
      • formatMinsAsDuration

        public String formatMinsAsDuration​(Object o)
      • formatMinsAsDuration

        public String formatMinsAsDuration​(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 20
        Parameters:
        o -
        numeric -
        Returns:
      • pad2

        public String pad2​(long l)
      • pad

        public String pad​(long l,
                          int length)
      • padWith

        public String padWith​(String padChar,
                              long l,
                              int length)
      • toPercent

        public String toPercent​(Object num,
                                Object div)
        Format as a percentage, including a percentage symbol and where blank/null values result in a blank output
        Parameters:
        num - - the numerator
        div - - the divisor
        Returns:
      • toPercent

        public String toPercent​(Object num,
                                Object div,
                                boolean appendSymbol,
                                boolean withBlanks)
        Parameters:
        num -
        div -
        appendSymbol - - if true the percentage symbol is appended if a non-blank value
        withBlanks - - if true, blank numerators or divisors result in a blank value. Otherwise return zero.
        Returns:
      • stripExt

        public String stripExt​(String s)
        Removes the file extension if present Eg file1.swf -> file1 file1 -> file1
        Parameters:
        s -
        Returns:
      • gt

        public boolean gt​(Object val1,
                          Object val2)
        True if val1 is greater then val2 will do string conversions
        Parameters:
        val1 -
        val2 -
        Returns:
      • percentDecode

        public String percentDecode​(String s)
        Decode percentage encoded paths. Eg a%20b -> a b
        Parameters:
        s -
        Returns:
      • toSqlDate

        public Date toSqlDate​(Object oVal)
      • getMonthName

        public String getMonthName​(int i)
Parameters:
b -
o1 -
o2 -
Returns: