How to remove milliseconds from a timestamp?
Had same issue had my initial timestamp stored in sq
and did sq.setTime(1000*(long)Math.floor(sq.getTime()/ 1000));
that does the job. In my case sq is a sql.Timestamp
If I understand you correctly there is no need to use Date / Calendar...
long yourmilliseconds = 1274883865399L;
long droppedMillis = 1000 * (yourmilliseconds/ 1000);
System.out.println(droppedMillis);
1274883865000
Or... if you wish to have date formatting...
Calendar c = Calendar.getInstance();
c.setTime(new Date(yourmilliseconds));
c.set(Calendar.MILLISECOND, 0);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm.ss.SSS'Z'");
sdf.setTimeZone(TimeZone.getTimeZone("GMT"));
System.out.println(sdf.format(c.getTime()));
2010-05-26T14:24.25.000Z