3

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.

Josh
  • 16,286
  • 25
  • 113
  • 158

1 Answers1

0

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.

w00
  • 26,172
  • 30
  • 101
  • 147
Ben Green
  • 3,953
  • 3
  • 29
  • 49
  • The date has to come in through a parameter because we sometimes manually call the jar with an older date to rerun old data. I'm looking for a way to do this through the eclipse IDE, not in the java code itself. – Josh Jan 25 '13 at 16:49