public Timestamp strToDate(int type){
Timestamp time = null;
DateFormat format2= new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date date = null;
Calendar cale = Calendar.getInstance();
cale.add(Calendar.DATE, type);
String tarday = new SimpleDateFormat("yyyy-MM-dd").format(cale.getTime())+" 00:00:00"; // String转Date try {
date = format2.parse(tarday);
System.out.println(date.getTime());
time = new Timestamp(date.getTime());
System.out.println(time.toString());
} catch (ParseException e) {
e.printStackTrace();
} return time;
}

type 为-1 表示获取昨天的日期,-2为前天的日期,以此类推。0 为今天的日期。

最新文章

  1. Photoshop、Illustrator思维导图笔记
  2. ABP督导项目(1)
  3. INADDR_ANY
  4. yum install maven
  5. Winform开发框架的重要特性总结
  6. [jquery] jQuery jsTree V3.2.1 基础Demo
  7. Parse--Saving Images(翻译)
  8. spark1.1.0部署standalone分布式集群
  9. 自己定义flash的宽和高
  10. C陷阱与缺陷(二)
  11. JavaScript嗅探执行神器-sniffer.js,你值得拥有!
  12. Swift3.0 函数闭包与OC Block
  13. 201521123024《Java程序设计》第7周学习总结
  14. about:firefox set
  15. go 使用 c接口
  16. Lua语法基础(二)
  17. [数学笔记Mathematical Notes]2-一个带对数的积分不等式
  18. jieba(杰巴)分词的三种模式
  19. Cookie的几点忠告
  20. VirtualBox--虚拟机网络设置1--(四种方式)

热门文章

  1. 私有静态方法private static method-值得用吗?
  2. 剑指offer-面试题3.二维数组中的查找
  3. LeeCode-Remove Linked List Elements
  4. C:\Program Files (x86)\Common Files\microsoft shared\TextTemplating\11.0
  5. 【转】android camera(四):camera 驱动 GT2005
  6. ASP.NET中连接数据库的各种方法
  7. UVA10199- Tourist Guide(割点)
  8. 从决策树学习谈到贝叶斯分类算法、EM、HMM
  9. LR实战之Discuz开源论坛——登录脚本
  10. ThinkPHP使用Memcached缓存数据