public class UtlDataTypes extends Object
This class MAY be used by end users, however it is not supported.
Constructor and Description |
---|
UtlDataTypes() |
Modifier and Type | Method and Description |
---|---|
static boolean |
canConvert(Class<?> sourceType,
Class<?> targetType)
Tests if a source type can be converted to a target type by this class.
|
static <T> T |
convert(Class<T> targetType,
Object value) |
static <T> T |
convertNumber(Class<T> targetType,
Number num) |
static String[] |
getEnumNames(Class<?> enumClass) |
static Date |
parseAsDate(Object value)
Attempts to parse the given value as a date.
|
public static final boolean canConvert(Class<?> sourceType, Class<?> targetType)
sourceType
- The source type.targetType
- The target type.public static final Date parseAsDate(Object value) throws IllegalArgumentException
If the given value is a date, the it is returned.
If the given value is a long, then it used to construct a date interpreted as the
number of milliseconds since the epoch, e.g a Date is constructed using new
Date.Date(long)
Otherwise the value's toString method will be invoked and an attempt will be made to parse it as a Date:
yyyy-MM-dd hh:mm:ss[.f...] [Z]where the first 2 token are passed into the the sql
Timestamp.valueOf(String)
and the final remaining argument is parsed via TimeZone.getTimeZone(String)
.
Chronic.parse(String)
interrepeted as a date in the past. If the
resulting parse produces a timespan the beginning of the timespan range is usedvalue
- The value to parse as a date.IllegalArgumentException
Copyright © 2019 Neeve Research, LLC. All Rights Reserved.