其他分享
首页 > 其他分享> > Calendar工具类获取月初和月末时间

Calendar工具类获取月初和月末时间

作者:互联网

  int month = 1;
  int year =2021;
  Calendar c1 = Calendar.getInstance();
  //设置本月起始日的年月日时分秒格式
  c1.set(year , month-1, 1, 0, 0, 0);
  String beginMonthTime = sdf.format(c1.getTime());
  //设置本月结束日的年月日时分秒格式
  c1.set(year , month-1, c1.getActualMaximum(Calendar.DAY_OF_MONTH), 23, 59, 59);
  String endMonthTime = sdf.format(c1.getTime());

标签:set,获取,getTime,month,月末,year,Calendar,c1
来源: https://blog.csdn.net/weixin_42231601/article/details/119247509