Re: Timestamp to a string



"Sandeep" <sandeepsinghal@xxxxxxxxx> wrote...
>I have to attach a timestamp to a string with optional date format. (
> to create a file )
>
> Eg:
> String str = new("filenameMM-DD-YYYY.txt");
> or
> String str = new("filename.txt");
>
> I need something like str.format(date) which would replace the date
> format (if present ) with the current timestamp.

People seem to be interpreting your question as "how do create and
concatenate a date string" which I think we can see it isn't. Your main
problem (it seems to me) is to recognize whether there is a date on the
filename presently. You have to derive a function to test for the presence
of a date which doesn't mistake some legitimate filename for your
concatenated string.

It isn't hard to do but you should isolate it into a single method
IsDatePresent() or something like that so you can adjust the code if you get
a false positive at some point. You know it should be attached to the end
of the filename, it should follow a 99-99-9999 convention and the filename
cannot be shorter than 11 characters or there couldn't be a date string
attached (it had to have at least one character initially).

If the filename passed was "test00-00-1234" you can see this might get by as
it coincidentally matches. In that case you could improve IsDatePresent(),
add a test for valid dates and this example would report False.

Tom


.



Relevant Pages

  • Re: characters and numbers in same output
    ... fid = fopen; ... or using %6.2f can get the correct A and B but FileName is ... you print 'FileName' as a string and then print the ... characters in the string 'FileName', the number stored in A, and the number ...
    (comp.soft-sys.matlab)
  • Re: How to exchange a string between a
    ... stimuli from a file given a filename and in which the filename can be ... The way I do it is to declare a large enough string for any filename in a package file: ... I am reading a filename out of a plain text script file, so when I do that, as I copy the filename into the string, I count the number of characters copied: ... end loop; ...
    (comp.lang.vhdl)
  • Re: Extract string w/ 7 characters
    ... Function stGetFileNameas String ... Will get tyou the filename. ... extract the contents of the file name to insert to the sheet name. ... example has more than 7 characters. ...
    (microsoft.public.excel.programming)
  • Re: folder and file names with foreign characters
    ... My need is to use a string to represent these fold and file names and then do copy, ... switch and try using that instead of the full "long" filename. ... I don't know whether XP would create a base font name or whether it might still have other characters in the filename or not, but it's one thing might try... ...
    (comp.soft-sys.matlab)
  • Re: file class
    ... private String _FileName; ... /// filename and all reqired parameters must be set up by user ... public TextFileServer(string FileName, int FixedRecordLen) ... //End of line built from constructor or user manual ...
    (microsoft.public.dotnet.languages.csharp)