title: casting long to int
body: <p>I have one variable which gets current time and stored in long. But I have to convert it to <strong>int</strong> as it is the requirement. So what i am doing is converting the val with (int) and storing inside the int.</p>
  
  <pre><code>Val = 1355399741522 (long)
  Int Val = -1809346991 (after casting to int)
  
  After Casting from int to long -&gt; Val = -1809346991 //TESTED
  </code></pre>
  
  <p>Now my question is if I want to convert this int again back to long than definitely it will not going to work for me. <strong>That i already tested.</strong> But I want alternate solution for this. </p>
  
  <p><strong>NOTE - I don't want to store long. As its the requirement. And I am using below function to convert the long to time</strong></p>
  
  <pre><code>public static String convertToTime(final long date) {
          String time = null;
          final SimpleDateFormat bartDateFormat1 = new SimpleDateFormat("HH");
          final SimpleDateFormat bartDateFormat2 = new SimpleDateFormat("mm");
          final Date fomDat = new Date(date);
          final int hour = Integer.parseInt(bartDateFormat1.format(fomDat));
          final int min = Integer.parseInt(bartDateFormat2.format(fomDat));
          time = pad(hour) + ":" + pad(min);
          return time;
      }
  </code></pre>
  
  <p>If anyone has any idea please kindly guide me or provide any alternative.</p>