I am new to android. i have video recording application where in i capture the video and store it, i need to store the video's name with the current date and time. so is there any way to do the same. Till i know the video names does not take the number format values..
String mediaFile;
File mediaStorageDir = new File(
Environment.getExternalStorageDirectory(), "/VideoLogger");
if (!mediaStorageDir.exists()) {
if (!mediaStorageDir.mkdirs()) {
Log.d("VideoLogger", "failed to create directory");
return null;
}
}
String timeStamp = new SimpleDateFormat("yyyy-MM-dd_HH-mm-ss")
.format(new Date());
if (!sufix.equals("movie")) {
mediaFile = mediaStorageDir.getPath() + File.separator + "output_"
+ timeStamp + "_" + sufix + ".txt";
} else {
mediaFile = mediaStorageDir.getPath() + File.separator + "output_"
+ timeStamp + ".mp4";
}
return mediaFile;
}
}
Here is the code that i use for naming my video file.
SimpleDateFormat date = new SimpleDateFormat("dd/MM/yyyy");//Give you current date currentDate = date.format(new Date());SimpleDateFormat time = new SimpleDateFormat("hh:mm a");//Give you current time currentTime = time.format(new Date());//Store like this filename = currentDate +"-"+currentTime +".mp4";