I fail to add seconds to Java Timestamp.
I have this, but, it gives me the same date:
int sec = 600;
java.sql.Timestamp ts_from_ws = new java.sql.Timestamp(retry_date);
Calendar cal = Calendar.getInstance();
cal.setTimeInMillis(ts_from_ws.getTime());
cal.add(Calendar.SECOND,sec);
java.sql.Timestamp ts_new_date_ws = new java.sql.Timestamp(cal.getTime().getTime());
The code you’ve got works for me. As a short but complete program:
Output:
Note the difference of 10 minutes, i.e. 600 seconds.
Of course you lose the sub-millisecond precision this way, which may well not be ideal – and it goes against what I’m normally use a timestamp for in the first place – but it does add the seconds…
Another option would be to just use
Timestampdirectly: