为了将天数添加到特定日期,我尝试过这样
calendar.setTime(currentDate);
calendar.add(Calendar.DAY_OF_YEAR, 7);
Date nextWeek = calendar.getTime();
System.out.format("next week: %s\n", nextWeek);
但我正在使用它来获取应用安装日期
PackageManager pm = getApplicationContext().getPackageManager();
ApplicationInfo appInfo = pm.getApplicationInfo(
"com.mothistorycheck.functions", 0);
String appFile = appInfo.sourceDir;
long installed = new File(appFile).lastModified();
Date date = new Date(installed * 1000L);
Date currentDate = Calendar.getInstance().getTime();
我想从这个安装日期提前 1 年,如何获得它。