How to convert a variable's datatype of a POJO from main method? any API
Do we have any API by which we can change the data type of a variable of a POJO from main method?
any API available for that? If so, Please provide me how to implement it.
Thank y开发者_高级运维ou so much,
Harish Raj.
Literally POJO: Plain Old Java Object, so it exposes it's datas via methods, if the POJO doesn't provide method to accesso its data in your desired format/type, you should access it via its methods and then perform conversion.
Now, let's dig a bit, you've got a java main, and a POJO, how's the POJO related to your main ? Is it a class referenced directly or you access it in some other ways ?
Please clarify your scenario.
Regards
public String convertToString(XMLGregorianCalendar cal)
{
return "" + cal.getYear() + "/" + cal.getMonth() + "/" + cal.getDay();
}
of course you may need to add some checks on nulls or values (written out of the box without thinkin much, but shall do the trick)
How is it possible to change the data type? You can only type cast the data but cannot convert the data type. What do you really mean by changing the datatype of a variable of POJO.
精彩评论