public class StringsToTypes extends Object
| Modifier and Type | Field and Description |
|---|---|
private static List<SimpleDateFormat> |
dateFormats |
private static List<SimpleDateFormat> |
dateTimeFormats |
private static Set<String> |
falseValues |
private static int |
OLD_ENUM_STYLE |
private static List<SimpleDateFormat> |
timeFormats |
private static Set<String> |
trueValues |
| Constructor and Description |
|---|
StringsToTypes() |
| Modifier and Type | Method and Description |
|---|---|
static Object |
callConstructor(Class<?> toWhat,
String value)
To retrieve instances of classes with a single string-argument constructor like
BigDecimal.BigDecimal(String), BigInteger.BigInteger(String). |
private static Field |
findOldStyleEnumField(Class<?> clazz,
String name) |
static Object |
getOldStyleEnumFieldValue(Class<?> toWhat,
String value)
Support for int/string enum pattern.
|
private static RuntimeException |
newRuntimeException(String value,
Class<?> toWhat) |
static boolean |
toBoolean(String value)
"true", "t", "yes", "y", "on", "1", "x", "-1" will return true.
"false", "f", "no", "n", "off", "0", "" will return false. |
static char |
toCharacter(String value) |
static Object |
toDate(String value) |
static Object |
toEnum(Class<?> toWhat,
String value) |
static Object |
toSqlDate(String value) |
static Object |
toTime(String value) |
static Object |
toTimestamp(String value) |
private static final int OLD_ENUM_STYLE
private static final List<SimpleDateFormat> dateTimeFormats
private static final List<SimpleDateFormat> dateFormats
private static final List<SimpleDateFormat> timeFormats
public static boolean toBoolean(String value)
@Nullable private static Field findOldStyleEnumField(@NotNull Class<?> clazz, String name)
public static Object getOldStyleEnumFieldValue(Class<?> toWhat, String value)
Locale.@NotNull public static Object callConstructor(@NotNull Class<?> toWhat, String value)
BigDecimal.BigDecimal(String), BigInteger.BigInteger(String).@NotNull private static RuntimeException newRuntimeException(String value, Class<?> toWhat)
public static char toCharacter(@NotNull
String value)
value - Can be empty.Character.UNASSIGNED, otherwise the first character of value.Copyright © 2020. All rights reserved.