Search code examples
spring-bootfilespring-cloud-streamspring-cloud-dataflowsink

Spring Cloud Data Flow Add TimeStamp to File Name


I am trying to use the out of the box file Source and Sink stream applications with Spring Cloud data flow. I am trying to move a file from one folder to another. When the file arrives at the sink I would like to rename it and append a date or timestamp to the file name. How do I do this? I assume the name-expression field but I am not sure what values this can take. Anything I try in this field seems to cause an error.

I would like the file to be something like test20191122.txt

file sink props


Solution

  • Something like...

    'test' + new java.text.SimpleDateFormat('yyyyMMdd').format(new java.util.Date()) + '.txt'
    

    ...should work.