gpt4 book ai didi

Android:无法解析构造函数 'Date()'

转载 作者:行者123 更新时间:2023-11-29 14:21:35 25 4
gpt4 key购买 nike

我收到此错误“无法解析构造函数‘Date()’”,我不知道为什么。

如果有人能解释我为什么得到它,我将不胜感激。

谢谢

代码:

/** Create a File for saving an image or video */
private File getOutputMediaFile(){
// To be safe, you should check that the SDCard is mounted
// using Environment.getExternalStorageState() before doing this.
File mediaStorageDir = new File(Environment.getExternalStorageDirectory()
+ "/Android/data/"
+ getApplicationContext().getPackageName()
+ "/Files");

// This location works best if you want the created images to be shared
// between applications and persist after your app has been uninstalled.

// Create the storage directory if it does not exist
if (! mediaStorageDir.exists()){
if (! mediaStorageDir.mkdirs()){
return null;
}
}
// Create a media file name
String timeStamp = new SimpleDateFormat("ddMMyyyy_HHmm").format(new Date());
File mediaFile;
String mImageName="camera_wiki"+ timeStamp +".jpg";
mediaFile = new File(mediaStorageDir.getPath() + File.separator + mImageName);
return mediaFile;
}

最佳答案

问题已通过使用正确的 Date 类解决:java.util.Date

关于Android:无法解析构造函数 'Date()',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29884388/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com