public static final long ONE_MONTH_INTERVAL=1000 * 60 * 60 * 24 * 30;public static final long THREE_MONTHS_INTERVAL=1000 * 60 * 60 * 24 * 90;

These 2 lines give me this warning :

Numeric overflow in expression

Rightfully indeed considering a long can reach 2,147,483,647 max and one month in milliseconds already reach 2,592,000,000

I was wondering how to avoid the overflow (beside converting it in seconds).

On a side note, how is :

long currentDate=System.currentTimeMillis();

Even working ? I mean milliseconds since epoch are much greater than 3 months, so how is it succssfully stored into a long ?

share|improve this question


public static final long ONE_MONTH_INTERVAL=1000L * 60L * 60L * 24L * 30L;public static final long THREE_MONTHS_INTERVAL=1000L * 60L * 60L * 24L* 90L;
share|improve this answer
  • Thank you very much for solving my problem ! Could you though give a bit more explanations ?– Sebastien FERRANDFeb 13 at 17:17
  • 2
    Multiplying like you mentioned is integer multiplication not long. So by defining L at the end of each number fixes that.– S.ElaiotrivarisFeb 13 at 17:18
  • 2
    Also for max value check Long class MAX_VALUE attribute.– S.ElaiotrivarisFeb 13 at 17:20

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.