Home arrow static arrow Java Programming [Archive] - file timestamp
Warning: Creating default object from empty value in /www/htdocs/w008deb8/wiki/components/com_staticxt/staticxt.php on line 51
Java Programming [Archive] - file timestamp
This topic has 2 replies on 1 page.

Posts:38
Registered: 5/28/04
file timestamp  
Aug 2, 2004 3:18 AM



 
i want to create a file using java that contains a timstamp for example

bookmark020704.csv

so it is like "bookmarks" + date and time + ".csv"

any suggestions on how to do this? as what i am doing at the moment isnt working

try {
Calendar calendar = Calendar.getInstance();
System.out.println(calendar.getTime());
File file = new File("CSVTESTFILE" + calendar.getTime() + ".csv");
file.createNewFile();
}
catch(Exception e){
System.out.println(e);
}

cheers

Andy
 

Posts:4,496
Registered: 19/06/02
Re: file timestamp  
Aug 2, 2004 3:31 AM (reply 1 of 2)



 
You can use DateFormat:
java.text.DateFormat df = new java.text.SimpleDateFormat("ddMMyy");String s = df.format(calendar.getTime());java.io.File file = new java.io.File("C:/CSVTESTFILE" + s + ".csv");
 

Posts:38
Registered: 5/28/04
Re: file timestamp  
Aug 2, 2004 3:38 AM (reply 2 of 2)



 
brilliant thank you
 
This topic has 2 replies on 1 page.