android - Why do I get a error date value? -
i use following code display details of photo, find value of myinfo.date 22:15 15-01-1970.
error made? thanks!
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 =long.parselong(date) ; calendar.settimeinmillis(now); date mydate = calendar.gettime(); simpledateformat sdf = new simpledateformat("hh:mm dd-mm-yyyy"); return sdf.format(mydate); }
i think need multiply 1000 :
date date=new date(cur.getlong(cur.getcolumnindex(mediastore.images.media.date_modified))*1000);
Comments
Post a Comment