public class Formatter extends Object
| Modifier and Type | Field and Description |
|---|---|
static String |
CHECKBOX_SUFFIX |
static ThreadLocal<DateFormat> |
sdfDateAndTime |
static ThreadLocal<DateFormat> |
sdfDateOnly |
static ThreadLocal<DateFormat> |
tlSdfUkLong |
static ThreadLocal<DateFormat> |
tlSdfUkShort |
| Constructor and Description |
|---|
Formatter() |
| Modifier and Type | Method and Description |
|---|---|
Date |
addDays(Date now,
int days)
Return a date which has the given number of days added (or subtracted if
negative) to the given date
|
String |
checkbox(String name,
Object oChecked) |
String |
checkbox(String id,
String name,
Object oChecked) |
String |
checkbox(String id,
String name,
Object oChecked,
String value) |
boolean |
eq(Object val1,
Object val2) |
String |
formatMinsAsDuration(Object o) |
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
|
int |
getDayOfMonth(Object o) |
int |
getMonth(Object o) |
String |
getMonthName(int i) |
int |
getYear(Object o) |
boolean |
gt(Object val1,
Object val2)
True if val1 is greater then val2
will do string conversions
|
String |
ifEqual(String ifEqual,
String ifNoteEqual,
Object o1,
Object o2) |
Object |
ifTrue(Object bb,
Object o1,
Object o2)
This just permits simple templating syntax for basic conditional values
Eg: $item.text
|
boolean |
lt(Object val1,
Object val2) |
String |
option(Object value,
String text,
Object currentValue)
Generate an option element
|
String |
pad(long l,
int length) |
String |
pad2(long l) |
String |
padWith(String padChar,
long l,
int length) |
String |
percentDecode(String s)
Decode percentage encoded paths.
|
String |
percentEncode(String s) |
String |
radio(String id,
String name,
Object oChecked,
String value) |
DateFormat |
sdf(boolean hasTime) |
String |
stripExt(String s)
Removes the file extension if present
Eg file1.swf -> file1
file1 -> file1
|
BigDecimal |
toBigDecimal(Object o,
int decimals) |
Boolean |
toBool(Object o) |
String |
toCsv(Iterable list) |
String |
toCsv(String[] list) |
Date |
toDate(Object oVal) |
BigDecimal |
toDecimal(Object o,
int places) |
Double |
toDouble(Object o) |
Long |
toLong(Object oLimit) |
Long |
toLong(Object oVal,
boolean withNulls) |
String |
toPercent(Object num,
Object div)
Format as a percentage, including a percentage symbol and where
blank/null values result in a blank output
|
String |
toPercent(Object num,
Object div,
boolean appendSymbol,
boolean withBlanks) |
String |
toPlain(String html) |
Date |
toSqlDate(Object oVal) |
Timestamp |
toSqlTimestamp(Object oVal) |
String |
toString(Object o)
Null safe method, returns empty string if the value is null
|
public static final String CHECKBOX_SUFFIX
public static ThreadLocal<DateFormat> tlSdfUkShort
public static ThreadLocal<DateFormat> tlSdfUkLong
public static final ThreadLocal<DateFormat> sdfDateOnly
public static final ThreadLocal<DateFormat> sdfDateAndTime
public String toString(Object o)
o - public BigDecimal toDecimal(Object o, int places)
public int getYear(Object o)
public int getMonth(Object o)
public int getDayOfMonth(Object o)
public String formatMinsAsDuration(Object o, boolean numeric)
o - numeric - public String pad2(long l)
public String pad(long l, int length)
public String toPercent(Object num, Object div)
num - - the numeratordiv - - the divisorpublic String toPercent(Object num, Object div, boolean appendSymbol, boolean withBlanks)
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.public String stripExt(String s)
s - public boolean gt(Object val1, Object val2)
val1 - val2 - public String percentDecode(String s)
s - public String getMonthName(int i)
public Object ifTrue(Object bb, Object o1, Object o2)
b - o1 - o2 - public DateFormat sdf(boolean hasTime)
public BigDecimal toBigDecimal(Object o, int decimals)
public String option(Object value, String text, Object currentValue)