-3

Can we put ":" in the name of a folder?

For example if I want that the name of my file(case) is the hour of today (on this form 14:38).

String outString = new SimpleDateFormat("dd-MM-yyyy hh-mm-ss").format(new Date());
File dossierphoto = new File(Environment.getExternalStorageDirectory() +
                             "/Dossier Client/" +
                             cli.getClientId() + "/" +
                             outString);
Mark Rhodes
  • 10,049
  • 4
  • 48
  • 51
John Snow
  • 21
  • 1
  • 3
  • 3
    Have you tried it? What did it do? Did you get any error messages? Try that first, then update your question accordingly – Matt Taylor Mar 26 '14 at 13:49
  • 1
    Please do some research with respect to allowable characters in filesystem names. Also, don't use `dd-MM-yyyy` for a date format - it doesn't sort well - use a big-endian ISO-8601 format such as `yyyy-MM-dd` instead. Also use HH instead of hh in order to use 24 hour clock format - 12 hour clock format also doesn't sort well. – Squonk Mar 26 '14 at 14:05

1 Answers1

3

No you can not put ":" char on folder name. You can use "_" char instead of ":". For example: 14_38.

Of course, you should change this char auto.

File dossierphoto = new File(Environment.getExternalStorageDirectory() + "/Dossier Client/" + cli.getClientId() + "/" + outString.replace(":","_"));

Arda Ç.
  • 504
  • 5
  • 7