so , you mean
if I use touch(id, 1800)
then expiry will be 30 minutes
and if I want to use time over 30 days, for example 90 days, then
int expiration = (int) MILLISECONDS.toSeconds(
System.currentTimeMillis() + DAYS.toMillis(90));
If you mean
touch(id, expiration), then yes.
But this value is to big for int type. for example I’ve tried to set
touch(id, 2592000000) ( as 90 days in ms ) and I’ve got an error that value is to big for Integer type.
The expiration value should not be 90 days in ms. The value you want is “The current time in seconds, plus 90 days in seconds”. If you prefer to think of it that way, an equivalent expression is:
int expiration = (int) (MILLISECONDS.toSeconds(System.currentTimeMillis())
Yes, there is the potential for integer overflow if the expiration is far enough in the future (see: year 2038 problem), but 90 days from September 14, 2018 is something like
1544739782 which fits in a signed integer just fine.