title: Java: Unix time in seconds to milliseconds
body: <p>I get a <strong>10 digit</strong> timestamp from a json file and I've just figured out that this is Unix time <em>in seconds and not in milliseconds</em>.</p>
  
  <p>So I went to my DateUtils class multiplied the timestamp in seconds with 1000, in order to convert it to timestamp in milliseconds.</p>
  
  <p>When I tried to test isToday(), this line of code gave me a year like 50000 something...</p>
  
  <pre><code>int otherYear = this.calendar.get(Calendar.YEAR);
  </code></pre>
  
  <p>What is the mistake here?</p>
  
  <p><strong>DateUtils.java</strong></p>
  
  <pre><code>public class DateUtils{
  
   public class DateUtils {
      private Calendar calendar;
  
      public DateUtils(long timeSeconds){
          long timeMilli = timeSeconds * 1000;
          this.calendar = Calendar.getInstance();
          this.calendar.setTimeInMillis(timeMilli*1000);
      }
      private boolean isToday(){
          Calendar today = Calendar.getInstance();
          today.setTimeInMillis(System.currentTimeMillis());
  
          // Todays date
          int todayYear = today.get(Calendar.YEAR);
          int todayMonth = today.get(Calendar.MONTH);
          int todayDay = today.get(Calendar.DAY_OF_MONTH);
  
          // Date to compare with today
          int otherYear = this.calendar.get(Calendar.YEAR);
          int otherMonth = this.calendar.get(Calendar.MONTH);
          int otherDay = this.calendar.get(Calendar.DAY_OF_MONTH);
  
          if (todayYear==otherYear &amp;&amp; todayMonth==otherMonth &amp;&amp; todayDay==otherDay){
              return true;
          }
          return false;
      }
  }
  </code></pre>