如果涉及到统计的话,可能会经常用到。很简单的基础知识。

1、getTimestampByOffsetDay

	public static long getTimestampByOffsetDay(int day){

		Calendar calendar = Calendar.getInstance();
calendar.add(Calendar.DAY_OF_MONTH, day);
calendar.set(Calendar.HOUR_OF_DAY, 0);
calendar.set(Calendar.SECOND, 0);
calendar.set(Calendar.MINUTE, 0);
calendar.set(Calendar.MILLISECOND, 0); return calendar.getTimeInMillis();
}

2、 getTodayTimestamp

	public static HashMap<String, Object> getTodayTimestamp(){

		HashMap<String, Object> hashMap = new HashMap<String, Object>();

		hashMap.put("startTime", getTimestampByOffsetDay(0));
hashMap.put("endTime", getTimestampByOffsetDay(1)); return hashMap;
}

3、getWeekTimestamp

	public static HashMap<String, Object> getWeekTimestamp() {

		HashMap<String, Object> hashMap = new HashMap<String, Object>();

		Calendar calendar = Calendar.getInstance();

		hashMap.put(
"startTime",
getTimestampByOffsetDay(0 - calendar.get(Calendar.DAY_OF_WEEK) + 2));
hashMap.put(
"endTime",
getTimestampByOffsetDay(calendar
.getMaximum(Calendar.DAY_OF_WEEK)
- calendar.get(Calendar.DAY_OF_WEEK) + 1)); return hashMap;
}
 
 
4、getMonthTimestamp
	public static HashMap<String, Object> getMonthTimestamp() {

		HashMap<String, Object> hashMap = new HashMap<String, Object>();

		Calendar calendar = Calendar.getInstance();

		hashMap.put(
"startTime",
getTimestampByOffsetDay(0 - calendar.get(Calendar.DAY_OF_MONTH) + 1));
hashMap.put(
"endTime",
getTimestampByOffsetDay(calendar
.getMaximum(Calendar.DAY_OF_MONTH)
- calendar.get(Calendar.DAY_OF_MONTH))); return hashMap;
}

最新文章

  1. Python调用C++的DLL
  2. JAVA学习遇到的问题:接口实现
  3. 使用MVVM框架(avalonJS)进行快速开发
  4. LR连接oracle时出现:SQLState=28000[Oracle][ODBC][Ora]ORA-01017:invalid username/password;logon denied
  5. 1.ARC和非ARC文件共存
  6. 致vi老大 2011.1
  7. html5 + css3 + zepto.js实现的微信广告宣传页
  8. Call-time pass-by-reference has been deprecated
  9. Python可迭代对象、迭代器和生成器
  10. Linux部署与基本指令
  11. Effective Java 第三版——2. 当构造方法参数过多时使用builder模式
  12. Week_10 C
  13. Python_装饰器精讲_33
  14. ajax 的一些参数
  15. 再谈git和github-深入理解
  16. eclipse开启时报错问题
  17. python成长之路五-文件操作
  18. JavaMail SMTP服务器发送邮件程序示例 java通过dns服务器解析ip地址
  19. Spring 基础概念——DI、IOC(一)
  20. SAP 以工序为基准进行发料 机加工行业 Goods Issue to Routing

热门文章

  1. IE浏览器中ajax使用缓存数据的问题
  2. Sass学习之路(4)——不同样式风格的输出方式
  3. sqlserver 存储过程 try catch TRANSACTION (转)
  4. Exchange Server 2013 一步步安装图解
  5. IOS 图片轮播实现原理 (三图)
  6. iOS 学习 - 5.UILabel设置行距
  7. Xcode找Library位置
  8. 软件测试作业1--描述Error
  9. hping3
  10. oracle表空间相关