I can't get date in properManner, I use PackageManager
:
Code example
::List<PackageInfo> applications = getPackageManager().getInstalledPackages(0);
for(PackageInfo info : applications){
// Drawable icon = info.applicationInfo.loadIcon(getBaseContext());
long firstInstalled = info.firstInstallTime;
long lastUpdate = info.lastUpdateTime;
System.out.pr开发者_运维知识库intln("firstInstalled"+firstInstalled);
if I print
firstInstalled to LOGCAT then I got result "firstInstalled is 1305907770197"
I can't able to understand what is this? can you help me?
Look right there in your code. It says long firstInstalled = info.firstInstallTime;
. It is a number representing the number of milliseconds since January 1, 1970 00:00:00 UTC.
Maybe you want a more readable representation of that info?
Calendar cal = Calendar.getInstance();
cal.setTimeInMillis(firstInstalled);
Now you can extract and display the values for hour, day, year, etc. from the cal
variable. See Calendar
for further info.
Use below code
Date d = new Date(firstInstalled);
d.getDate();
d.getMonth();
d.getYear();
精彩评论