Reputation: 225
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.
Upvotes: 16
Views: 48505
Reputation: 152
Use toString()
method of any Boolean
, e.g.:
Boolean flag = true
String value = flag.toString()
Upvotes: 6
Reputation: 790
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
Upvotes: 21