Android Countdown Issue
<p>I've been working on a live ticker and with the help of some code I found on the internet i've managed to find something that is sort of working.</p>

<p>I'm getting a date out of a database and splitting it and putting it into milliseconds and this is where the code I found takes over.</p>

<p>Now the rest of it works out perfect except for the days, it seems to be always 30 days plus however many is left??</p>

<p>This is the code:</p>

<pre><code>        GregorianCalendar endDate = new GregorianCalendar(Integer.parseInt(separated[0]), Integer.parseInt(separated[1]),  Integer.parseInt(separated[2]), Integer.parseInt(Time[0]), Integer.parseInt(Time[1]), 00);
    GregorianCalendar startDate = new GregorianCalendar(year, month, day, hours, minutes, seconds);

    long diffInMs = endDate.getTimeInMillis() - startDate.getTimeInMillis();


    new CountDownTimer(diffInMs, 1000) {

         public void onTick(long millisUntilFinished) { 
             int seconds = (int)(millisUntilFinished / 1000) % 60 ;
             int minutes = (int)((millisUntilFinished / (1000*60)) % 60);
             int hours = (int)((millisUntilFinished / (1000*60*60)) % 24);
             int days = (int)((millisUntilFinished / (1000*60*60*24)) % 365);
             //int years = (int)(millisUntilFinished / 1000*60*60*24*365);

             ArrayList&lt;String&gt; timeArray = new ArrayList&lt;String&gt;();

    //               if(years &gt; 0)   
    //                   timeArray.add(String.valueOf(years)   + "y");

             if(days &gt; 0)    
                 timeArray.add(String.valueOf(days) + "d");

             if(hours&gt;0)   
                 timeArray.add(String.valueOf(hours) + "h");

             if(minutes&gt;0) 
                 timeArray.add(String.valueOf(minutes) + "min");

             if(seconds&gt;0) 
                 timeArray.add(String.valueOf(seconds) + "sec");

             String time = "";
             for (int i = 0; i &lt; timeArray.size(); i++) 
             {
                 time = time + timeArray.get(i);
                 if (i != timeArray.size() - 1)
                     time = time + ", ";
             }

             if (time == "")
               time = "0 sec";

             Countdown.setText("Database Lock: " + time );


         }
</code></pre>

<p>Now I can't see why the days would work out wrong?</p>

<p>Any ideas on what might be wrong?</p>

<p>Thanks,
Chris</p>
