I am having a quite annoying problem. I want to get the current date/time and insert it into a filename but I can't for my life get it to work.
I want to get the time as 2011-11-18 12:13:57 and then insert it into my filename
filename-2011-11-18-12:13:57.tar.gz
I have tried SimpleDateFormat
etc. but it just won't work!
(I am writing in Eclipse Indigo)
filename_2011-11-18_12-13-57.tar.gz
. In other words, separatefilename
from thedate
with an underscore and separate thedate
from thetime
with an underscore and replace the:
in thetime
with a-
. This would be much easier tosplit
if necessary and would use valid characters for a file name. – Squonk Nov 18 '11 at 12:08