Java Code Examples for cn.hutool.core.date.DateUtil#endOfDay()
The following examples show how to use
cn.hutool.core.date.DateUtil#endOfDay() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NodeWelcomeController.java From Jpom with MIT License | 6 votes |
private PageResult<SystemMonitorLog> getList(String time, long millis) { long endTime = System.currentTimeMillis(); long startTime = endTime - TimeUnit.MINUTES.toMillis(30); if (StrUtil.isNotEmpty(time)) { // 处理时间 List<String> list = StrSpliter.splitTrim(time, "~", true); DateTime startDate = DateUtil.parseDateTime(list.get(0)); startTime = startDate.getTime(); DateTime endDate = DateUtil.parseDateTime(list.get(1)); if (startDate.equals(endDate) || StrUtil.equalsAny("00:00:00", endDate.toString(DatePattern.NORM_TIME_FORMAT), startDate.toString(DatePattern.NORM_TIME_FORMAT))) { endDate = DateUtil.endOfDay(endDate); } endTime = endDate.getTime(); } int count = (int) ((endTime - startTime) / millis); NodeModel node = getNode(); // 开启了节点信息采集 Page pageObj = new Page(1, count); pageObj.addOrder(new Order("monitorTime", Direction.DESC)); Entity entity = Entity.create(); entity.set("nodeId", node.getId()); entity.set(" MONITORTIME", ">= " + startTime); entity.set("MONITORTIME", "<= " + endTime); return dbSystemMonitorLogService.listPage(entity, pageObj); }
Example 2
Source File: BaseServerController.java From Jpom with MIT License | 6 votes |
/** * 处理分页的时间字段 * * @param page 分页 * @param entity 条件 * @param colName 字段名称 */ protected void doPage(Page page, Entity entity, String colName) { String time = getParameter("time"); colName = colName.toUpperCase(); page.addOrder(new Order(colName, Direction.DESC)); // 时间 if (StrUtil.isNotEmpty(time)) { String[] val = StrUtil.split(time, "~"); if (val.length == 2) { DateTime startDateTime = DateUtil.parse(val[0], DatePattern.NORM_DATETIME_FORMAT); entity.set(colName, ">= " + startDateTime.getTime()); DateTime endDateTime = DateUtil.parse(val[1], DatePattern.NORM_DATETIME_FORMAT); if (startDateTime.equals(endDateTime)) { endDateTime = DateUtil.endOfDay(endDateTime); } // 防止字段重复 entity.set(colName + " ", "<= " + endDateTime.getTime()); } } }
Example 3
Source File: UserServiceImpl.java From sdb-mall with Apache License 2.0 | 6 votes |
@Override public Integer getYestodayNewUsers() { List<Filter> filterList = new ArrayList<>(); Filter start = new Filter(); start.setOperator(Filter.Operator.ge); start.setProperty("create_date"); Date todayBegin = DateUtil.beginOfDay(new Date()); todayBegin = DateUtil.offsetDay(todayBegin, -1); start.setValue(todayBegin); filterList.add(start); Filter end = new Filter(); end.setOperator(Filter.Operator.le); end.setProperty("create_date"); Date todayEnd = DateUtil.endOfDay(new Date()); todayEnd = DateUtil.offsetDay(todayEnd, -1); end.setValue(todayEnd); filterList.add(end); List<User> userList = this.findByFilters(filterList); return userList.size(); }
Example 4
Source File: HutoolController.java From mall-learning with Apache License 2.0 | 5 votes |
@ApiOperation("DateUtil使用:日期时间工具") @GetMapping(value = "/dateUtil") public CommonResult dateUtil() { //Date、long、Calendar之间的相互转换 //当前时间 Date date = DateUtil.date(); //Calendar转Date date = DateUtil.date(Calendar.getInstance()); //时间戳转Date date = DateUtil.date(System.currentTimeMillis()); //自动识别格式转换 String dateStr = "2017-03-01"; date = DateUtil.parse(dateStr); //自定义格式化转换 date = DateUtil.parse(dateStr, "yyyy-MM-dd"); //格式化输出日期 String format = DateUtil.format(date, "yyyy-MM-dd"); //获得年的部分 int year = DateUtil.year(date); //获得月份,从0开始计数 int month = DateUtil.month(date); //获取某天的开始、结束时间 Date beginOfDay = DateUtil.beginOfDay(date); Date endOfDay = DateUtil.endOfDay(date); //计算偏移后的日期时间 Date newDate = DateUtil.offset(date, DateField.DAY_OF_MONTH, 2); //计算日期时间之间的偏移量 long betweenDay = DateUtil.between(date, newDate, DateUnit.DAY); return CommonResult.success(null, "操作成功"); }
Example 5
Source File: OrderMasterServiceImpl.java From sdb-mall with Apache License 2.0 | 5 votes |
@Override public List<OrderMaster> getTodayTotalOrders() { List<Filter> filterList = new ArrayList<>(); Filter start = new Filter(); start.setOperator(Filter.Operator.ge); start.setProperty("create_date"); Date todayBegin = DateUtil.beginOfDay(new Date()); start.setValue(todayBegin); filterList.add(start); Filter end = new Filter(); end.setOperator(Filter.Operator.le); end.setProperty("create_date"); Date todayEnd = DateUtil.endOfDay(new Date()); end.setValue(todayEnd); filterList.add(end); Filter payFilter = new Filter(); payFilter.setOperator(Filter.Operator.eq); payFilter.setProperty("pay_status"); payFilter.setValue(PayStatusEnum.SUCCESS); filterList.add(payFilter); List<OrderMaster> orderMasterList = this.findByFilters(filterList); return orderMasterList; }
Example 6
Source File: OrderMasterServiceImpl.java From sdb-mall with Apache License 2.0 | 5 votes |
@Override public List<OrderMaster> getTodayOrders() { List<Filter> filterList = new ArrayList<>(); Filter start = new Filter(); start.setOperator(Filter.Operator.ge); start.setProperty("create_date"); Date todayBegin = DateUtil.beginOfDay(new Date()); start.setValue(todayBegin); filterList.add(start); Filter end = new Filter(); end.setOperator(Filter.Operator.le); end.setProperty("create_date"); Date todayEnd = DateUtil.endOfDay(new Date()); end.setValue(todayEnd); filterList.add(end); Filter orderFilter = new Filter(); orderFilter.setOperator(Filter.Operator.ne); orderFilter.setProperty("order_status"); orderFilter.setValue(OrderStatusEnum.CANCEL); filterList.add(orderFilter); List<OrderMaster> orderMasterList = this.findByFilters(filterList); return orderMasterList; }