Command Line Parameter for current date and time in eclipse

1.2k Views Asked by At

I have a java application that writes a file. One of my command line parameters is the name of the file. I would like to set a run configuration in eclipse to name the file with the date and time, something like this:

MyFile_20121018113400.txt

Is there a way to do this in the Run Configurations menu?

EDIT: The date format doesn't have to be exactly that. I just want a unique filename for each time I generate the file.

1

There are 1 best solutions below

1
On

I am new to Stack Overflow, so apologies if I get this wrong or have misunderstood the question, but can you use:

Date currentDate = new Date();

And format it with a simple date formatter, for example:

dateFormatter = new SimpleDateFormat("yyyy-MM-dd");

And then change the format to whatever your want?

Again, apologies if this is unhelpful.