Im using the following code to convert type object to string,
fieldValue
defined as is type object .
keyl.put(fieldName, (String) fieldValue);
the values of the type object can be only java types such as
java decimal ,byte,float, calendar ,date etc ...
when i got in fieldValue
value of java.util.date
I got an exception since the casting is not success.
how can i overcome this issue?
If you want to get String representation of Object you can use fieldValue.toString()
method. In case fieldValue
can be primitive type (it wont have any methods) you can use String.valueOf(fieldValue)
.
String is an Object but all the Objects are not Strings.
The cast can be to its own class type or to one of its subclass or superclass types or interfaces.
There are some rules of Object type casting in Java id it's a primitive type you can do
String.valueOf(fieldValue)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With