public class CommonUtils extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
DEFAULT_DATE_FORMAT_PATTERN
Default date format.
|
Constructor and Description |
---|
CommonUtils() |
Modifier and Type | Method and Description |
---|---|
static java.util.regex.Pattern |
compilePattern(java.lang.String regex)
|
static java.util.regex.Pattern |
compilePattern(java.lang.String regex,
int flags)
|
static java.util.regex.Pattern |
compilePattern(java.lang.String regex,
java.lang.String message)
|
static java.lang.Object |
convertTo(java.lang.String valueString,
java.lang.String typeName)
Converts a String value to an object of the specified type and wraps the
Exceptions into a
ConQATException |
static java.text.SimpleDateFormat |
createDateFormat(java.lang.String pattern)
Create
SimpleDateFormat from pattern string. |
static <T> T |
defaultIfNull(T input,
T defaultValue)
Returns the input.
|
static <T> boolean |
isOneOf(T obj,
java.util.Collection<T> others)
Check if obj is equal to one of the provided objects.
|
static <T> boolean |
isOneOf(T obj,
T... others)
Check if obj is equal to one of the provided objects.
|
static java.nio.charset.Charset |
obtainEncoding(java.lang.String encodingName)
Get an encoding for the specified name.
|
static java.util.Date |
parseDate(java.lang.String dateString,
java.lang.String formatString)
This method parses a date string using the specified format pattern.
|
static ConQATException |
wrapPatternSyntaxException(java.util.regex.PatternSyntaxException e)
Wraps a
PatternSyntaxException into a ConQATException |
public static final java.lang.String DEFAULT_DATE_FORMAT_PATTERN
public CommonUtils()
public static java.text.SimpleDateFormat createDateFormat(java.lang.String pattern) throws ConQATException
SimpleDateFormat
from pattern string. In contrast to the
constructor of SimpleDateFormat
this raises a
ConQATException
for invalid patterns.ConQATException
public static java.util.Date parseDate(java.lang.String dateString, java.lang.String formatString) throws ConQATException
SimpleDateFormat
for pattern syntax.ConQATException
- if an illegal format string was supplied or the date string
does not match the given format.public static java.util.regex.Pattern compilePattern(java.lang.String regex) throws ConQATException
ConQATException
public static java.util.regex.Pattern compilePattern(java.lang.String regex, java.lang.String message) throws ConQATException
ConQATException
public static java.util.regex.Pattern compilePattern(java.lang.String regex, int flags) throws ConQATException
ConQATException
public static ConQATException wrapPatternSyntaxException(java.util.regex.PatternSyntaxException e)
PatternSyntaxException
into a ConQATException
public static java.nio.charset.Charset obtainEncoding(java.lang.String encodingName) throws ConQATException
ConQATException
if the encoding is not supported.ConQATException
public static java.lang.Object convertTo(java.lang.String valueString, java.lang.String typeName) throws ConQATException
ConQATException
ConQATException
public static <T> T defaultIfNull(T input, T defaultValue)
null
.@SafeVarargs public static <T> boolean isOneOf(T obj, T... others)
public static <T> boolean isOneOf(T obj, java.util.Collection<T> others)