SimpleDateFormat sdf=new SimpleDateFormat("yyyyMMddHHmmss");
Calendar c = new GregorianCalendar();
java.util.Date date = new java.util.Date();
c.setTime(date);
c.add(Calendar.SECOND, -7*24*3600);
java.util.Date dateBefore = c.getTime();//两种把Calendar转化成Long类型的方法(毫秒)
Calendar c = new GregorianCalendar();
java.util.Date date = new java.util.Date();
c.setTime(date);
c.add(Calendar.SECOND, -7*24*3600);
java.util.Date dateBefore = c.getTime();//两种把Calendar转化成Long类型的方法(毫秒)
long nowDate= dateBefore.getTime();//把时间换算成毫秒
把"yyyy-MM-dd HH:mm:ss"格式时间转化成long(毫秒)
SimpleDateFormat sd=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Calendar cal = Calendar.getInstance();
try {
cal.setTime(sd.parse(endtime));
} catch (ParseException e) {
}
long starttime = cal.getTimeInMillis();