我正在为我拍照的andorid开发一个应用程序。问题是我只以毫秒为单位保存 conseguidor 当前时间,我想输入当前日期(dd / mm / yyyy)。
这是我的代码:
PictureCallback jpegCallback = new PictureCallback()
{
public void onPictureTaken(byte[] data, Camera camera)
{
FileOutputStream outStream = null;
try
{
outStream = new FileOutputStream(String.format("/mnt/extSdCard/Photos/%d.jpg", System.currentTimeMillis()));
outStream.write(data);
outStream.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
}
}
};
我试图把这个,但不工作我得到错误:
Calendar c = Calendar.getInstance();
String day = Integer.toString(c.get(Calendar.DATE));
String month = Integer.toString(c.get(Calendar.MONTH));
String year = Integer.toString(c.get(Calendar.YEAR));
String name = day + "/" + month + "/" + year + ".jpg";
String folder = "/mnt/extSdCard/Photos/";
String path = folder + name;
...
outStream = new FileOutputStream(String.format(path));
outStream.write(data);
outStream.close();
任何人都可以帮助我吗?