Java怎么得到昨天的日期???? java 有沒有得到昨天日期的函數?Help!!!!!! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 先取今天,然后减去1天的时间就得到了。如:Date d=new Date();d=new Date(d.getTimes()-1000*3600-24);//昨天或者用Calendar类。 Calendar rightNow = Calendar.getInstance(); GregorianCalendar gc1 = new GregorianCalendar(rightNow.get(Calendar.YEAR), rightNow.get(Calendar.MONTH), rightNow.get(Calendar.DAY_OF_MONTH)); gc1.add(Calendar.DATE, -1); Date d1 = (Date)gc1.getTime(); Calendar cal = Calendar.getInstance();cal.add(Calendar.DATE, -1);String yesterday = new SimpleDateFormat("yyyy-MM-dd").format(cal.getTime()); 謝謝﹗輸出的月份是Tue Jul 31 09:21:45 CST 2007能不能控制格式象月份Jul要把它轉換具體數字7﹐這個怎么做? Date date = new Date();date.setTime(date.getTime()-24*60*60*1000); SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");Date dd = df.format(date); 求助:谁有Struts2-core-2.1.8.1 的源码? JSP不定项选择,为什么实现不了? 用java读写同一access中的两个表,哪位给个例子啊. 在java中如何结束进程? 怎么处理,请高手指点 如何在SQL查询语句中取得变量的值? 有关STATIC的问题 哪位朋友有关于介绍MAP比较详细的网址?在线等待 十分费解的一个问题帮我解决 关于swing中的一个问题,向各位朋友请教 打包成JAR后不能找到图片 请教网页游览器视频音频实现
如:
Date d=new Date();
d=new Date(d.getTimes()-1000*3600-24);//昨天或者用Calendar类。
GregorianCalendar gc1 = new GregorianCalendar(rightNow.get(Calendar.YEAR), rightNow.get(Calendar.MONTH),
rightNow.get(Calendar.DAY_OF_MONTH));
gc1.add(Calendar.DATE, -1);
Date d1 = (Date)gc1.getTime();
cal.add(Calendar.DATE, -1);
String yesterday = new SimpleDateFormat("yyyy-MM-dd").format(cal.getTime());
能不能控制格式象月份Jul要把它轉換具體數字7﹐這個怎么做?
Date dd = df.format(date);