public class GenericTypeValidator extends Object implements Serializable
Constructor and Description |
---|
GenericTypeValidator() |
Modifier and Type | Method and Description |
---|---|
static Byte |
formatByte(String value)
Checks if the value can safely be converted to a byte primitive.
|
static Byte |
formatByte(String value,
Locale locale)
Checks if the value can safely be converted to a byte primitive.
|
static Long |
formatCreditCard(String value)
Checks if the field is a valid credit card number.
|
static Date |
formatDate(String value,
Locale locale)
Checks if the field is a valid date.
|
static Date |
formatDate(String value,
String datePattern,
boolean strict)
Checks if the field is a valid date.
|
static Double |
formatDouble(String value)
Checks if the value can safely be converted to a double primitive.
|
static Double |
formatDouble(String value,
Locale locale)
Checks if the value can safely be converted to a double primitive.
|
static Float |
formatFloat(String value)
Checks if the value can safely be converted to a float primitive.
|
static Float |
formatFloat(String value,
Locale locale)
Checks if the value can safely be converted to a float primitive.
|
static Integer |
formatInt(String value)
Checks if the value can safely be converted to a int primitive.
|
static Integer |
formatInt(String value,
Locale locale)
Checks if the value can safely be converted to an int primitive.
|
static Long |
formatLong(String value)
Checks if the value can safely be converted to a long primitive.
|
static Long |
formatLong(String value,
Locale locale)
Checks if the value can safely be converted to a long primitive.
|
static Short |
formatShort(String value)
Checks if the value can safely be converted to a short primitive.
|
static Short |
formatShort(String value,
Locale locale)
Checks if the value can safely be converted to a short primitive.
|
public static Byte formatByte(String value)
value
- The value validation is being performed on.public static Byte formatByte(String value, Locale locale)
value
- The value validation is being performed on.locale
- The locale to use to parse the number (system default if
null)public static Short formatShort(String value)
value
- The value validation is being performed on.public static Short formatShort(String value, Locale locale)
value
- The value validation is being performed on.locale
- The locale to use to parse the number (system default if
null)public static Integer formatInt(String value)
value
- The value validation is being performed on.public static Integer formatInt(String value, Locale locale)
value
- The value validation is being performed on.locale
- The locale to use to parse the number (system default if
null)public static Long formatLong(String value)
value
- The value validation is being performed on.public static Long formatLong(String value, Locale locale)
value
- The value validation is being performed on.locale
- The locale to use to parse the number (system default if
null)public static Float formatFloat(String value)
value
- The value validation is being performed on.public static Float formatFloat(String value, Locale locale)
value
- The value validation is being performed on.locale
- The locale to use to parse the number (system default if
null)public static Double formatDouble(String value)
value
- The value validation is being performed on.public static Double formatDouble(String value, Locale locale)
value
- The value validation is being performed on.locale
- The locale to use to parse the number (system default if
null)public static Date formatDate(String value, Locale locale)
The Locale
is used with java.text.DateFormat
. The DateFormat.setLenient(boolean)
method is set to false
for all.
value
- The value validation is being performed on.locale
- The Locale to use to parse the date (system default if null)public static Date formatDate(String value, String datePattern, boolean strict)
The pattern is used with java.text.SimpleDateFormat
.
If strict is true, then the length will be checked so '2/12/1999' will
not pass validation with the format 'MM/dd/yyyy' because the month isn't
two digits. The DateFormat.setLenient(boolean)
method is set to false
for all.
value
- The value validation is being performed on.datePattern
- The pattern passed to SimpleDateFormat
.strict
- Whether or not to have an exact match of the
datePattern.Copyright © 2002–2017 The Apache Software Foundation. All rights reserved.