获取当前日期的前一天

Date dNow = new Date();   //当前时间
Date dBefore = new Date();

Calendar calendar = Calendar.getInstance(); //得到日历
calendar.setTime(dNow);//把当前时间赋给日历
calendar.add(Calendar.DAY_OF_MONTH, -1);  //设置为前一天
dBefore = calendar.getTime();   //得到前一天的时间


(Date d=new Date(System.currentTimeMillis()+10*1000))

String s=new SimpleDateFormat("YYYY-MM-DD hh:mm:ss").format(d);

你可能感兴趣的:(Date)