title: Android date with added milliseconds not at the correct time
body: <p>What I am trying to do is store a date, represented by a long of milliseconds, that is the next midnight from the current time. So, posting this at 10:11 PM, I would want a date representing 12:00 AM tomorrow morning. For this task, I wrote this line of code (knowing that there are 86400000 milliseconds in one day):</p>
  
  <pre><code>long time = System.currentTimeMillis() + (86400000 - (System.currentTimeMillis() % 86400000));
  </code></pre>
  
  <p>The line is designed to calculate the extra milliseconds from the last midnight, substract that from one whole day to find the time until the next midnight, then add that to the current time so that the new value is the value of the next midnight. For whatever reason though, the date object I am using to debug spits out "Wed Apr 20 20:00:00 EDT 2016" when calling the #toString() method. The current time is said to be "Tue Apr 19 22:08:34 EDT 2016" at the same time as the other date is being calculated.</p>
  
  <p>This means that the long of milliseconds is actually representing 8:00 PM the next day, while I want it to represent 12:00 AM. Can anyone help me spot the flaw in my logic?</p>
  
  <p>I most likely am missing something obvious, so bear with me.</p>
  
  <p>NOTE: I also tried calculating the time like this:</p>
  
  <pre><code>long time = System.currentTimeMillis() - (System.currentTimeMillis() % 86400000) + 86400000;
  </code></pre>
  
  <p>But this resulted in the same Date object.</p>