Reputation: 1213
I am trying to get the current date and add it as part of a string, but it is not working. This is what I have:
In User Defined Variables
currentDate ${__time(dd/MM/yyyy)}
And then later:
CurrentDate = vars.get("currentDate");
TestFile = vars.get("testFile-" + CurrentDate + ".txt");
f = new FileOutputStream(TestFile, true);
Upvotes: 0
Views: 889
Reputation: 168002
testFile-31/03/2016.txt
?Actually there are some reserved characters which cannot be used in file names, i.e.
< (less than)
> (greater than)
: (colon)
" (double quote)
/ (forward slash)
\ (backslash)
| (vertical bar or pipe)
? (question mark)
* (asterisk)
I would suggest to:
Reconsider your pattern
Remove vars.get
at all so your code would look like:
import java.text.SimpleDateFormat;
sdf = new SimpleDateFormat("dd-MM-yyyy");
TestFile = "testFile-" + sdf.format(new Date()) + ".txt";
f = new FileOutputStream(TestFile, true);
References:
Upvotes: 1