获取当前时间的00:00:00:000 和 当月1日00:00:00:000

 获取当天时间的00:00:00:000

Calendar calendar = Calendar.getInstance();
calendar.setTime(new Date());
calendar.set(Calendar.HOUR_OF_DAY, 0);
calendar.set(Calendar.MINUTE, 0);
calendar.set(Calendar.SECOND, 0);
long currentTime = calendar.getTimeInMillis() / 1000 * 1000 ;

 获取当月1日00:00:00:000

Calendar c = Calendar.getInstance();
c.set(c.get(Calendar.YEAR), c.get(Calendar.MONTH),1,0,0,0);
currentMonthFirstDayTime = c.getTime().getTime() / 1000 * 1000;

 

你可能感兴趣的:(java基础)