Forum Discussion
This is the important part of the error:
No signature of method: java.lang.Integer.getAt() is applicable for argument types: (java.lang.Integer) values: [0]Possible solutions: getAt(java.lang.String)
This means that the .toInteger() method (of which java.lang.Integer.getAt() is a sub-method) requires input of an object of a certain type. You passed in an object that could not be converted to an integer. This means that either h or m doesn’t contain a string that can be converted to an integer. .toInteger() needs a string to convert to an integer. It looks like you’re passing in either a “0” (integer) or [0] (list). I can’t tell which one because java debugging requires a higher state of consciousness to decipher.
If you’re still using the script from here, the issue is in the “toInteger()” method, which is happening at this point in your script. Here are some suggestions on how to troubleshoot it.
// get the values of hours and minutes from time_blocked. time_blocked will be something like 18:53
// so h should end up being 18 (in this case)
// and m should end up being 53 (in this case)
(h,m) = row.time_blocked.split(":")
// put a println statement here to see what h and m are to make sure they are convertable to integers
println("h=${h}\nm=${m}")
// if h and m look like integers here, then you shouldn't have any problems converting them to integers.
// if this line still doesn't work, it may be that there are extra spaces. In that case, use .trim() to remove any extra spaces
time_blocked = h.trim().toInteger()*60 + m.trim().toInteger()
// You can also split these lines up into their individual steps to see which one is failing
intHours = h.toInteger()
intMinutes = m.toInteger()
time_blocked = intHours * 60 + intMinutes
// if h and m look like this:
// h=[18]
// m=[53]
// then you don't have strings, you have a list of strings. You'd need to extract the elements from the list:
time_blocked = h[0].toInteger()*60 + m[0].toInteger()
Give some of these suggestions a try and see what you get. Check the output of the println statement to see if you’re getting valid values from the .split() method.
There are other ways to parse a string into an integer, but your first order of business is to find out what h and m contain after the .split() happens.
Related Content
- 2 years ago
- 3 days ago
- 2 years ago