欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

java 日榜周榜

程序员文章站 2022-06-30 16:34:26
...

java 日榜周榜

select sum(ag.diamondsnumber) diamondsnumber,ag.userid from artificer_gift ag where ag.artificerid=1  and ag.gifttime between '2019-08-01 00:00:00' and '2019-11-29 24:59:59' GROUP BY ag.userid  ORDER BY diamondsnumber DESC 

日榜
改其中时间即可,这是获取日榜时间

SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
		String nowtime = sdf.format(new Date());
		String startTime = nowtime + " 00:00:00";
		String endTime = nowtime + " 23:59:59";

周榜
这是获取周榜时间

SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
		Calendar calendar1 = Calendar.getInstance();
		Calendar calendar2 = Calendar.getInstance();
		int dayOfWeek = calendar1.get(Calendar.DAY_OF_WEEK) - 1;
		int offset1 = 1 - dayOfWeek;
		int offset2 = 7 - dayOfWeek;
		calendar1.add(Calendar.DATE, offset1 - 7);
		calendar2.add(Calendar.DATE, offset2 - 7);
		String lastBeginDate = sdf.format(calendar1.getTime());
		String lastEndDate = sdf.format(calendar2.getTime());
		String startTime = lastBeginDate + " 00:00:00";
		String endTime = lastEndDate + " 23:59:59";

java 日榜周榜

相关标签: java日榜周榜查询