Custom JQL function with date function as parameter

I need to create custom JQL function which will have two parameters: For example, startOfDay() and endOfDay() or startOfWeek() and endOfWeek().

Although, Jira Server JQL doesn’t allow nested JQL function calls. So I can’t do jql-query like mycustomfunction(startOfDay(), endOfDay()).

I get a syntax error in the JQL Query without quotation marks so I have to use quotation marks ( for example - mycustomfunction(“startOfDay()”, “endOfDay()”) ). But in this case I am sending text strings as parameters instead of values (dates).

Is there any way to get date from JQL “startOfDay(”-1w") in Java using Jira classes? Or there is another way to create custom JQL function with date function as parameter?