rdp9090 Posted June 29, 2017 Share Posted June 29, 2017 I'm having trouble displaying the correct dates on the variable expression I set. On 1 variable, I have the expression new SimpleDateFormat("MM/dd").format(new Date()) which correctly displays the current date, and on another variable, new SimpleDateFormat("MM/dd").format(new Date().getTime() - 7* 24 * 60 * 60 * 1000)which correctly displays the date 7 days ago. However, when I try new SimpleDateFormat("MM/dd").format(new Date().getTime() - 30* 24 * 60 * 60 * 1000)The date goes up into 07/19, which is 20 days forward rather than 30 days backwards. Could anyone explain why this occurs, and how I could get the correct date out of this? Link to comment Share on other sites More sharing options...
Solution Friendly User Posted June 29, 2017 Solution Share Posted June 29, 2017 Possible the equation 30* 24 * 60 * 60 * 1000 overflows because that value is way to big for an integer to store. Might want to try something like 30L * 24 * 60 * 60 * 1000 so it forces to a Long. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now