0
我正在使用数组列表来存储过去5周的时间戳列表。时间戳列表覆盖之前的时间戳
i.e., if today is 2014-06-09, I want to store
2014-06-02
2014-05-26
2014-05-19
2014-05-12
2014-05-05
这是我的代码。
public class Test {
public static void main(String ap[]) throws InterruptedException{
List<Timestamp> ts = new ArrayList<Timestamp>();
Timestamp t = new Timestamp(new java.util.Date().getTime());
Timestamp temp = null;
for(int i=0;i<5;i++){
t.setTime(t.getTime()-(7*24 * (long)60* (long)60) * (long)1000);
temp = t;
System.out.println(t);
ts.add(temp);
temp = null;
}
}
}
但问题始终是我得到overrided值即列表,列表中包含的所有元素在去年timestampI即2014年5月5日) 任何人能回答这个问题?