我有一个问题,如何使用此日期时间格式(dd-mm-yyyy hh:mm:ss)创建一个名称为完整日期时间的文件夹而不是此(dd-mm-yyyy hh-mm-ss)。
例如:
此行创建文件夹。
String outString = new SimpleDateFormat("dd-MM-yyyy hh-mm-ss").format(new Date());
File dossierphoto = new File(Environment.getExternalStorageDirectory() + "/Dossier Client/" + cli.getClientId() + "/" + outString);
但这条线没有做任何事情
String outString = new SimpleDateFormat("dd-MM-yyyy hh:mm:ss").format(new Date());
File dossierphoto = new File(Environment.getExternalStorageDirectory() + "/Dossier Client/" + cli.getClientId() + "/" + outString);
答案 0 :(得分:1)
试试这个
// Create an image file name
String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
String FileName = JPEG_FILE_PREFIX + timeStamp + "_";
File F = File.createTempFile(FileName, "IMG_");
答案 1 :(得分:1)
filename = "Trim"
+ (new SimpleDateFormat("yyyyMMdd_HHmmss", Locale
.getDefault())).format(new Date()) + ".mp4";
答案 2 :(得分:0)
你可以尝试这种方法
static SimpleDateFormat dateFormat = new SimpleDateFormat("dd-MMM-yyyy");
static String todayDate = dateFormat.format(new Date());
File file = new File(Environment.getExternalStorageDirectory() + "/Dossier Client/"+todayDate);
if (!file.exists()) {
try {
file.mkdir();
} catch (IOException e) {
e.printStackTrace();
}
}