Hi,
I use a Adaptavist ScriptRunner Listener to calculate a Date/Time field and its value. But it's somehow not working.
Can you spot my mistake?
def dateofDeployDate = new GregorianCalendar(2020, 10, 1, 4, 30, 0)
def days = 1
def hours = 2
def mins = 3
def tempScheduledEndDate = new GregorianCalendar()
tempScheduledEndDate = dateofDeployDate.add(Calendar.DATE, days)
tempScheduledEndDate = dateofDeployDate.add(Calendar.HOUR, hours)
tempScheduledEndDate = dateofDeployDate.add(Calendar.MINUTE, mins)
In this example I want to calculate an "End of Deployment"-Time. I do this on basis of a dateofDeployDate (2020-10-01 at 4:30:00 a.m.) and want to simply add 1 day, 2 hours and 3 minutes. So the result of tempScheduledEndDate would be 2020-10-02 at 6:33:00 a.m).
But the build in compiler of scriptrunner tells me an error that says: Cannot find matching mehtod
Thanks in Advance.
hi @Andreas Lorz the correct script is:
def dateofDeployDate = new GregorianCalendar(2020, 10, 1, 4, 30, 0)
def days = 1
def hours = 2
def mins = 3
def tempScheduledEndDate = new GregorianCalendar()
dateofDeployDate.add(Calendar.DATE, days) //add method is void method, you are just "adding something" to existing instance
dateofDeployDate.add(Calendar.HOUR, hours)
dateofDeployDate.add(Calendar.MINUTE, mins)
tempScheduledEndDate = dateofDeployDate
Did it help?
hi @Martin Bayer _MoroSystems_ s_r_o__ ,
unfortunately not. The error keeps the same.
But of course you are correct that I can just call the method
Any other guess?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi @Andreas Lorz I just tested the script, so I know it's working (at least for me :)). What Java version is used by your Jira instance? Could you attach some screenshot of the error?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Martin,
I used your rare script (not in my actual project) and it worked.
Ok, I must admit that I used for simplification not my original script. That wasn't clever. I worked the whole time with String like '42' not with the integer. That was the reason why it also not recognice the method. When I use Integer.parseInt in my code it works.
Thanks Martin for the help :)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Oh @Andreas Lorz I know the feeling :D
That's why I sometimes hate simplifications in Groovy when comparing it with pure Java.
But I'm happy it is working for you now...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.