i try some method,but not success,help me.
PackageInfo.firstInstallTime gives you the install time in "Unix time" (the time in milliseconds since "the epoch", i.e. January 1, 1970 00:00:00 UTC). You may use java.util.Date or java.text.DateFormat in order to format this time.
private static final String TAG = "MyActivity";
...
packageName = ...
...
try {
PackageInfo packageInfo = pm.getPackageInfo(packageName, PackageManager.GET_PERMISSIONS);
Date installTime = new Date( packageInfo.firstInstallTime );
Log.d(TAG, "Installed: " + installTime.toString());
Date updateTime = new Date( packageInfo.lastUpdateTime );
Log.d(TAG, "Updated: " + updateTime.toString());
}
catch ( PackageManager.NameNotFoundException e ) {
e.printStackTrace();
}
You can also change the date format with java.text.SimpleDateFormat.
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String installTime = dateFormat.format( new Date( packageInfo.firstInstallTime ) );
Log.d(TAG, "Installed: " + installTime);
String updateTime = dateFormat.format( new Date( packageInfo.lastUpdateTime ) );
Log.d(TAG, "Updated: " + updateTime);