我正在嘗試構建一個圖庫應用程序。我已經從MediaStore.Images
中添加了獲取的圖像路徑和日期。從Gallery返回的日期總是返回1970年1月1日
我用下面的代碼:
請參閱我已經發布below.The圖像路徑即將完美的logcat的,所以在milliseconds.But的時候,我試圖在毫秒轉換成日期格式,然後我總是得到:1970年1月17日
09-16 11:10:53.994: I/System.out(10098): date in format--->January 17, 1970 8:49PM
09-16 11:10:53.994: I/System.out(10098): Imagepath-->/storage/emulated/0/ModFace/Modface727142626.jpg
09-16 11:10:53.994: I/System.out(10098): date--->1437988950
09-16 11:10:53.994: I/System.out(10098): date in format--->January 17, 1970 8:56PM
09-16 11:10:53.994: I/System.out(10098): Imagepath-->/storage/emulated/0/ModFace/Modface727142639.jpg
09-16 11:10:53.994: I/System.out(10098): date--->1437988950
09-16 11:10:53.994: I/System.out(10098): date in format--->January 17, 1970 8:56PM
09-16 11:10:53.994: I/System.out(10098): Imagepath-->/storage/emulated/0/data/data/images/SILogo2015.png
09-16 11:10:53.994: I/System.out(10098): date--->1438252547
09-16 11:10:53.994: I/System.out(10098): date in format--->January 17, 1970 9:00PM
09-16 11:10:53.994: I/System.out(10098): Imagepath-->/storage/emulated/0/Download/ebook.png
09-16 11:10:53.994: I/System.out(10098): date--->1438668694
09-16 11:10:53.994: I/System.out(10098): date in format--->January 17, 1970 9:07PM
09-16 11:10:53.994: I/System.out(10098): Imagepath-->/storage/emulated/0/DCIM/Camera/20150811_153514.jpg
09-16 11:10:53.994: I/System.out(10098): date--->1439287514
09-16 11:10:53.994: I/System.out(10098): date in format--->January 17, 1970 9:18PM
09-16 11:10:53.994: I/System.out(10098): Imagepath-->/storage/emulated/0/Pictures/mainstreamtemp.jpg
09-16 11:10:53.994: I/System.out(10098): date--->1439800096
09-16 11:10:53.994: I/System.out(10098): date in format--->January 17, 1970 9:26PM
09-16 11:10:53.994: I/System.out(10098): Imagepath-->/storage/emulated/0/Pictures/mainstream2.jpg
09-16 11:10:53.994: I/System.out(10098): date--->1439800096
09-16 11:10:53.994: I/System.out(10098): date in format--->January 17, 1970 9:26PM
09-16 11:10:54.024: I/System.out(10098): date in format--->January 17, 1970 10:01PM
09-16 11:10:54.024: I/System.out(10098): Imagepath-->/storage/emulated/0/shiatoolkitimages/mashlool07.gif
09-16 11:10:54.024: I/System.out(10098): date--->1441888058
09-16 11:10:54.024: I/System.out(10098): date in format--->January 17, 1970 10:01PM
09-16 11:10:54.024: I/System.out(10098): Imagepath-->/storage/emulated/0/shiatoolkitimages/mashlool08.gif
09-16 11:10:54.024: I/System.out(10098): date--->1441888058
09-16 11:10:54.024: I/System.out(10098): date in format--->January 17, 1970 10:01PM
09-16 11:10:54.024: I/System.out(10098): Imagepath-->/storage/emulated/0/shiatoolkitimages/mashlool09.gif
09-16 11:10:54.024: I/System.out(10098): date--->1441888058
09-16 11:10:54.024: I/System.out(10098): Imagepath-->/storage/emulated/0/shiatoolkitimages/mashlool10.gif
09-16 11:10:54.024: I/System.out(10098): date--->1441888058
09-16 11:10:54.024: I/System.out(10098): Imagepath-->/storage/emulated/0/shiatoolkitimages/mashlool11.gif
09-16 11:10:54.024: I/System.out(10098): date in format--->January 17, 1970 10:01PM
09-16 11:10:54.024: I/System.out(10098): Imagepath-->/storage/emulated/0/siat_hadith.png
09-16 11:10:54.024: I/System.out(10098): date--->1442042302
09-16 11:10:54.024: I/System.out(10098): date in format--->January 17, 1970 10:04PM
我也曾嘗試另一種方法來轉換日期米利斯,但最終得到相同的結果:
public static String convertDate(long dateInMilliseconds,String dateFormat) {
return DateFormat.format(dateFormat, dateInMilliseconds).toString();
}
或使用'TimeUnit' –
謝謝您reply.I會嘗試。 – kgandroid
它的工作。謝謝。 – kgandroid