Here is my below code, cannot convert a string to double
def double ap = Double.parseDouble(String.valueOf(annualPremium))
Exception : because (of) (Stack trace: groovy.lang.MissingMethodException: No signature of method: static java.awt.geom.Arc2D$Double.parseDouble() is applicable for argument types: (java.lang.String) values: [878.22]
ok now step back and disasemble:
we expecting ap to be double
so we call function to parse STRING to double by calling parseDouble and as input we send result of valueOf(with some string) which returns number based on text, so our error is to put on Input of parseDouble an NUMBER instead of STRING.
https://www.tutorialspoint.com/java/java_string_valueof.htm
correct command:
def double ap = Double.parseDouble(annualPremium)