我使用以下代码显示照片的详细信息,但我发现 myInfo.date 的值是 22:15 15-01-1970。
我犯了什么错误?谢谢!
public static void GetPhotoDetailsByID(Context mycontext,String id,DetailsInfo myInfo ) {
Cursor cur = mycontext.getContentResolver().query(
MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
null,
MediaStore.Images.Media._ID+"=?",
new String[]{id},
"" );
if (cur.moveToFirst()){
myInfo.title= cur.getString(cur.getColumnIndex(MediaStore.Images.Media.TITLE));
myInfo.path = cur.getString(cur.getColumnIndex(MediaStore.Images.Media.DATA));
myInfo.size=cur.getString(cur.getColumnIndex(MediaStore.Images.Media.SIZE));
myInfo.date=cur.getString(cur.getColumnIndex(MediaStore.Images.Media.DATE_MODIFIED));
myInfo.date=GetDate(mycontext,myInfo.date);
/*
myInfo.resolution=cur.getString(cur.getColumnIndex(MediaStore.Images.Media.WIDTH))
+" x "
+cur.getString(cur.getColumnIndex(MediaStore.Images.Media.HEIGHT));
*/
myInfo.thumbnails = MediaStore.Images.Thumbnails.getThumbnail(
mycontext.getContentResolver(),
Integer.parseInt(id),
MediaStore.Images.Thumbnails.MICRO_KIND,
null);
}
cur.close();
}
private static String GetDate(Context mycontext,String date){
Calendar calendar = Calendar.getInstance();
long now =Long.parseLong(date) ;
calendar.setTimeInMillis(now);
Date myDate = calendar.getTime();
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm dd-MM-yyyy");
return sdf.format(myDate);
}