0
点赞
收藏
分享

微信扫一扫

获取某月第一天和最后一天

小磊z 2023-04-14 阅读 74

Calendar   ca   =   Calendar.getInstance(); 
ca.setTime(new Date());   //   someDate   为你要获取的那个月的时间 
ca.set(Calendar.DAY_OF_MONTH,   1); 
Date   firstDate   =   ca.getTime(); 
ca.add(Calendar.MONTH,   1); 
ca.add(Calendar.DAY_OF_MONTH,   -1); 
Date   lastDate   =   ca.getTime();  
 
System.out.println(firstDate.toLocaleString());
System.out.println(lastDate.toLocaleString());

举报

相关推荐

0 条评论