public static Date getBeginTime(int year, int month) {
        YearMonth yearMonth = YearMonth.of(year, month);
        LocalDate localDate = yearMonth.atDay(1);
        LocalDateTime startOfDay = localDate.atStartOfDay();
        ZonedDateTime zonedDateTime = startOfDay.atZone(ZoneId.of("Asia/Shanghai"));
        return Date.from(zonedDateTime.toInstant());
    }
 
    public static Date getEndTime(int year, int month) {
        YearMonth yearMonth = YearMonth.of(year, month);
        LocalDate endOfMonth = yearMonth.atEndOfMonth();
        LocalDateTime localDateTime = endOfMonth.atTime(23, 59, 59, 999);
        ZonedDateTime zonedDateTime = localDateTime.atZone(ZoneId.of("Asia/Shanghai"));
        return Date.from(zonedDateTime.toInstant());
    }

©著作权归作者所有:来自51CTO博客作者caoqishun的原创作品,如需转载,请注明出处,否则将追究法律责任

每一份赞赏源于懂得

赞赏

0人进行了赞赏支持

更多相关文章

  1. 获取当天最大或最小日期
  2. Pycharm 查看代码引用时,想跳回到上一步 设置
  3. MP4:文件类型mp42转码方案
  4. jenkins相关
  5. Nginx 1.18.0配置SSL问题
  6. Django 使用正则匹配URL 并将匹配成功的值传递给视图函数
  7. Table 'mysql.user' doesn't exist解决方案
  8. lnmp一键安装包搭建lnmp环境,二种方式
  9. 收藏分享:众多PPT模板,分享给需要的你!

随机推荐

  1. jQuery: 刨根问底 attr and prop两个函数
  2. jQuery轻量级圆形进度指示器插件
  3. 与symfony一起使用ajax时出现500内部服务
  4. jquery解析php通过ajax传过来的json二维
  5. java前端实时绘制不连续时间点多系列折线
  6. 从ajax查询返回的数组看起来还可以,但是它
  7. jQuery datepicker在IE8中遇到麻烦?
  8. 基于JQuery+JSP的无数据库无刷新多人在线
  9. Access-Control-Allow-Origin不允许使用O
  10. 自定义滚动条插件