title: How to remove milliseconds from a timestamp?
body: <p>I was asked this question :</p>
  
  <p>Given a timestamp as a long value, write a utility function in Java to drop the milliseconds.
  For example, given an input of 1274883865399 (actual time: 20100526T14:24:25.399Z), the
  function would return 1274883865000 (actual time: 2010-05-26T14:24:25.000Z)</p>
  
  <p>I did this :</p>
  
  <pre><code>import java.text.*;
  import java.util.*;
  
  public class ClearMilliSeconds {
      public static void main(String[] args) {   
  
          long yourmilliseconds = 1274883865399L;
          SimpleDateFormat sdf = new SimpleDateFormat("MMM dd,yyyy HH:mm");
           Calendar c = Calendar.getInstance();
  
  
          Date resultdate = new Date(yourmilliseconds);
          c.set(Calendar.MILLISECOND, 0);
          resultdate.setTime(c.getTimeInMillis());
          System.out.println(sdf.format(resultdate)); 
  }
  }
  </code></pre>
  
  <p>But it did not give me the right result</p>