I have a class that looks like following.
Class Parser{
private String fileName;
Parser(String fileName){
this.fileName = fileName;
}
}
Now I want to instantiate this class using Spring but problem is that fileName here is not constant. It is of following format FileToBeParsed_<ddMMyyyy> where ddMMyyyy is current date time(whenever instantiation happens).
So I was thinking of writing a utility method to generate correct filename but how do I inject it in constructor?
Also is it a good practice to create beans of third party/library/JDK classes in your spring configuration.
Thanks
Assuming you’re using a version of spring that supports spring EL, then this should work for you: