Use this to get the right time:
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); Date date = new Date(); String timeStamp = dateFormat.format(date.toLocaleString());
and you can create your file as follows:
FileOutputStream out = context.openFileOutput(timeStamp , context.MODE_PRIVATE); out.write(string.getBytes()); out.close();
source share