Thursday, February 7, 2013

ADF BC Groovy with Java Imports

ADF BC Groovy expressions support is really great and often saves a lot of time in development of complex functionalities. It comes very handy when retrieving referenced data or calling custom ADF BC methods. There is one more hidden gem offered by ADF BC Groovy - option to import Java packages directly into Groovy and use Java functionality.

Here is the example - I'm importing java.text.SimpleDateFormat directly from Groovy expression and then using Java formatting to retrieve month and year portion from current date. This expression is defined for default value of the transient attribute:

Simple and no headache - it just works:

Here you can download sample application for this post -


Anonymous said...

thank you

Anonymous said...

Great discovery Andrejus, never would have thought of that. Can be very helpfull.


Filip Huysmans

Andrejus Baranovskis said...

Sounds good Filip ! :)


MarioT said...

Hi! wonderful post. does this works on any jdev version ? we are not currently working with the last release. we are on

Andrejus Baranovskis said...

I think it should work with any version. But I was testing only with the latest JDev.


Nigel Cheetham said...

Hi Andrejus,

This doesn't work with JDeveloper 12c ( - you get the following error:

Unexpected exception caught: org.codehaus.groovy.control.MultipleCompilationErrorsException, msg=startup failed:
General error during semantic analysis: JBO-25152: Calling the constructor for class java.text.SimpleDateFormat is not permitted.

Andrejus Baranovskis said...

It could be a bug in 12c. I will need to test, on my todo list.