Here's 3 options:
1. At startup
You can define the required SystemProperty when launching your Spring Boot Application:
public static void main(String[] args) {
System.setProperty("timestamp",String.valueOf(System.currentTimeMillis()));
new SpringApplicationBuilder() //
.sources(Launcher.class)//
.run(args);
}
Then, define your property in application.properties just the way you did:
screenshot.path = C:/Automation/${timestamp}
2. At Injection
@Value("${screenshot.path}")
public void setScreenshotPath(String screenshotPath) {
this.screenshotPath =
screenshotPath.replace("${timestamp}", System.currentTimeMillis());
}
3. At usage - dynamic timestamps at execution
@Value("${screenshot.path}")
private String screenshotPath;
...
new File(screenshotPath.replace("${timestamp}", System.currentTimeMillis());
//or the following without the need for ${timestamp} in screenshot.path
//new File(screenshotPath + System.currentTimeMillis());