Convert Double to String Groovy

1
0
-1

Please i need your help, on a Groovy script i need to concat a Double value to an string as you can see on the next line of code:

def script = "";
script = "UPDATE crm_caso SET MontoProyecto = "+String.valueOf(varGlobalMontoDiseno)+"  WHERE CodCaso ='"+varGlobalIdCaso+"'";

And i have tryed the next change but it doesnt work:

def script = "";
script = "UPDATE crm_caso SET MontoProyecto = "+varGlobalMontoDiseno.toString()+"  WHERE CodCaso ='"+varGlobalIdCaso+"'";

I cant find the way to do it.

The variable "varGlobalIdCaso" is a Double

Thanks in advance for your help.

1 answer

1
0
-1
This one is the BEST answer!

Hi.

When you concat a string with a double (or other number) you don't need to change it in a String. I think you can use this :

def script = "";
script = "UPDATE crm_caso SET MontoProyecto = "+varGlobalMontoDiseno+" WHERE CodCaso ='"+varGlobalIdCaso+"'";

If you want to change your double in String you can do this :

def script = "";
script = "UPDATE crm_caso SET MontoProyecto = "+Double.toString(varGlobalMontoDiseno)+" WHERE CodCaso ='"+varGlobalIdCaso+"'";

Comments

Submitted by minerodo on Thu, 01/22/2015 - 22:16

thanks!

Notifications