def setOnePlueOne(def user, def booleanValue) {
updateAnswerAttribute(userRandy, ??????)
..
}
so what i have to do to convert that boolean
to string and updateAnswerAttribute
as "true" or "false" in DB.
Added getter and setter
public Boolean setOnePlueOne() {
return OnePlueOne;
}
public void getOnePlueOne(Boolean onePlueOne) {
this.onePlueOne = onePlueOne;
now I need to convert that (Boolean onePlueOne) in string (true or false) and send it through set method to def booleanValue
.
def setOnePlueOne(def user, def booleanValue) {
updateAnswerAttribute(userRandy, ??????) this will update or create value in DB
To convert Boolean to String in Java, use the toString() method. For this, firstly, we have declared two booleans. String str1 = new Boolean(bool1). toString(); String str2 = new Boolean(bool2).
You can convert True and False to strings 'True' and 'False' with str() . Non-empty strings are considered True , so if you convert False to strings with str() and then back to bool type with bool() , it will be True .
Use the String object to convert a boolean to a string in TypeScript, e.g. const str = String(bool) . When used as a function, the String object converts the passed in value to a string and returns the result. Copied! The String function takes a value as a parameter and converts it to a string.
The two best ways of doing this are :
String.valueOf(booleanValue)
Boolean.toString(booleanValue)
Though the preferred is the first one as second gives null pointer when booleanValue = null.
Best approach to converting Boolean object to string in java
Use: anyBooleanValue.toString()
Example:
Boolean flag=true
String value=flag.toString()
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