I’m using Spring framework and I don’t know how to do this simple thing:
I want to provide a String to a bean, with the string being the result of the concatenation of multiple part, some fixed and other variables
For example it could be something like:
"myReportFile_20102101_1832.txt"
– the first part is a fixed part
– the second part is a timestamp with current date time
– the last part is another fixed part
How to achieve that using the simplest way ?
Thanks a lot.
That sounds like a Job for the Spring Expression Language (introduced in Spring 3.0) to me. Though it might be easier to use a factory bean for that task (it gets the static information injected via IOC and offers a factory method that instantiates your other bean including the calculated dynamic information). Like so
And then in your bean configuration something like