Calendar’s add method in Java takes an integer as an input
int secs = 3; cal.add(Calendar.SECOND, secs);
But what if the seconds are Long type.
long secs = 3
There’s quite a few possibilities like adding the seconds iterative, but what are the other options?
If the value stored in
long secis less or equal thenInteger.MAX_VALUEyou can cast toint:If the value is less or equal
Long.MAX_VALUE / 1000then you can convert the seconds to milliseconds and use a different approach: