日期:2014-05-19 浏览次数:20653 次
public static void main(String[] args) {
Calendar c = Calendar.getInstance();
long l = c.getTimeInMillis();
long res = l - 24 * 3600 * 1000;
c.setTimeInMillis(res);
String s = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(res);
String st = "2012-12-02 12:12:20";//要传的参数
SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date d = null;
try {
d = sf.parse(st);
} catch (ParseException e) {
e.printStackTrace();
}
long t = d.getTime();
long p = t - 24 * 3600 * 1000;
String test = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(p);
System.out.println(test);
}
select * from lduser where (makedate =(select current_date - 1 day from dual) and maketime >=(select current_time from dual ) ) or (makedate =(select current_date from dual ) and maketime <(select current_time from dual))
--如果你的时间字段为字符串类型
WHERE T.TIME BETWEEN TO_CHAR(SYSDATE-1,'YYYY-MM-DD HH24:MI:SS') AND TO_CHAR(SYSDATE,'YYYY-MM-DD HH24:MI:SS')
--如果你的时间字段为data类型
WHERE T.TIME BETWEEN SYSDATE-1 AND SYSDATE
Calendar c=Calendar.getInstance();
Date currentDate=c.getTime();//当前系统时间
c.add(Calendar.DAY_OF_YEAR,-1);//当前时间减去一天即昨天的这个时间
Date yesterDay=c.getTime();//获取昨天
//currentDate和yesterDay就是你要的时间条件了