public static void main(String[] args) throws Exception {
// long cur = System.currentTimeMillis();
long cur = new Date().getTime();
System.out.println(cur);
System.out.println("一个小时前:\t" + new Date(cur - 1000 * 60 * 60));
System.out.println("一天前:\t\t" + new Date(cur - 1000 * 60 * 60 * 24));
System.out.println("3个星期前:\t"
+ new Date(cur - 1000 * 60 * 60 * 24 * 7 * 3));
System.out.println("4个星期前:\t"
+ new Date(cur - 1000 * 60 * 60 * 24 * 7 * 4));
}
1446516404943
一个小时前: Tue Nov 03 09:06:44 CST 2015
一天前: Mon Nov 02 10:06:44 CST 2015
3个星期前: Tue Oct 13 10:06:44 CST 2015
4个星期前: Wed Nov 25 03:09:32 CST 2015
------解决思路----------------------
1000 * 60 * 60 * 24 * 7 * 4越界了,超过了int类型的字长
改成(long) 1000 * 60 * 60 * 24 * 7 * 4试试