Revision 2630 org.gvsig.tools/library/trunk/org.gvsig.tools/org.gvsig.tools.lib/src/main/java/org/gvsig/tools/dataTypes/DataTypeUtils.java
DataTypeUtils.java | ||
---|---|---|
148 | 148 |
public static String toString(Object value, String defaultValue) { |
149 | 149 |
return (String) coerce(DataTypes.STRING, value, defaultValue); |
150 | 150 |
} |
151 |
|
|
152 |
public static String toString(Locale locale, Object value, String defaultValue) { |
|
153 |
Coercion coercer = getCoercion(DataTypes.STRING); |
|
154 |
try { |
|
155 |
String x = (String) coercer.coerce(value, CoercionContextLocale.create(locale)); |
|
156 |
if( x == null ) { |
|
157 |
return defaultValue; |
|
158 |
} |
|
159 |
return x; |
|
160 |
} catch (CoercionException ex) { |
|
161 |
return defaultValue; |
|
162 |
} |
|
163 |
} |
|
151 | 164 |
|
152 | 165 |
public static Date toDate(Object value, Date defaultValue) { |
153 | 166 |
return (Date) coerce(DataTypes.DATE, value, defaultValue); |
Also available in: Unified diff