java Android从今天起30天
我需要我的应用VIP功能从今天起30天到期,我将在应用程序配置中存储当前日期。如何检查VIP功能是否已过期?我不介意用户是否将时钟倒转,应用程序是否正常工作
当用户激活VIP功能时
mCurrentUser.setVip();
mCurrentUser.SaveInBackgroud();
// in want to also set StartDate and EndDate
然后验证mCurrentUser endDate中保存的日期是否与今天一致
// set user to no VIP! like
mCurrentUser.setNoVip();
mCurrentUser.SaveInBackgroud();
# 1 楼答案
您可以通过以下方法从给定日期起30天后获得日期
然后你可以比较两个日期
如果为true,则时间已过期
# 2 楼答案
如果你想让它在30天后的第二天到期,他启动了vip,你可以使用这个:
要启动计时器:
在创建mainActivity时,要检查用户每次打开应用程序的时间是否已过:
在服务器上存储时间戳时,或者如果你想在应用程序中显示准确的倒计时,这种方法也很好