public final class CommonUtils
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
NOT_AVAILABLE |
Modifier and Type | Method and Description |
---|---|
static void |
closeReader(java.io.Reader reader) |
static java.lang.String |
collectionToCommaDelimitedString(java.util.Collection<java.lang.String> list)
Convert a List of Strings to a comma delimited String.
|
static java.lang.String |
getLocalTime(java.util.Date date,
java.util.TimeZone timeZone)
Return a date/time formatted String for the provided
Date and TimeZone . |
static java.lang.String |
getTimeZoneNameWithOffset(java.util.TimeZone timeZone)
Returns the timezone name as well as the UTC offset.
|
static boolean |
isValidEmail(java.lang.String emailAddress) |
static java.lang.String |
maskPassword(java.lang.String password)
Simple method to replace characters in a String with asterisks to mask the password.
|
static java.lang.String |
padRight(java.lang.String string,
int size)
Right-pad the provided String with empty spaces.
|
static java.lang.String |
padRight(java.lang.String inputString,
int size,
char paddingChar)
Right-pad a String with a configurable padding character.
|
public static final java.lang.String NOT_AVAILABLE
public static java.lang.String padRight(java.lang.String inputString, int size, char paddingChar)
inputString
- The String to pad. A null
String will be treated like an empty String.size
- Pad String by the number of characters.paddingChar
- The character to pad the String with.public static java.lang.String padRight(java.lang.String string, int size)
string
- The String to padsize
- Pad String by the number of characters.public static java.lang.String collectionToCommaDelimitedString(java.util.Collection<java.lang.String> list)
list
- public static void closeReader(java.io.Reader reader)
reader
- public static boolean isValidEmail(java.lang.String emailAddress)
emailAddress
- The email address to validatetrue
if the provided email address is valid; false
otherwisepublic static java.lang.String maskPassword(java.lang.String password)
password
- The password to maskpublic static java.lang.String getLocalTime(java.util.Date date, java.util.TimeZone timeZone)
Date
and TimeZone
.
Uses the DateFormat
provided by TimeUtils.getDefaultDateTimeFormat()
If the date is null
NOT_AVAILABLE
is returned.date
- Can be nulltimeZone
- Must not be nullpublic static java.lang.String getTimeZoneNameWithOffset(java.util.TimeZone timeZone)
timeZone
- Must not be null