java获得某个月的天数
2024-09-20 14:11:57
/**
* 方法一
*/
String strDate = "2012-02";
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM");
Date date = format.parse(strDate);
Calendar calendar = new GregorianCalendar();
calendar.setTime(date);
int days1 = calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
System.out.println("天数为=" + days1);
/**
* 方法二
*/
int days2 = new Date(2012,02,0).getDate();
System.out.println("天数为=" + days2);
最新文章
- Windows Azure Virtual Machine (26) 使用高级存储(SSD)和DS系列VM
- 【leetcode】Spiral Matrix(middle)
- php发送post包
- pyenv 以及 virtualenv
- [POJ] #1006# Biorhythms : 最小公倍数/同余问题
- mybatis错误:Invalid bound statement (not found)
- IIS Server Farms集群负载
- 扩展ASP.NET MVC HtmlHelper类
- ajax 实现加载页面、删除、查看详细信息,以及bootstrap网页的美化
- 3016: [Usaco2012 Nov]Clumsy Cows
- api-gateway实践(14)前端签名密钥和后端签名密钥
- LocalBroadcastManager—创建更高效、更安全的广播
- 【RL-TCPnet网络教程】第26章 RL-TCPnet之DHCP应用
- 【OJ】抓牛问题
- 001_python单元测试
- 微信硬件平台(七)微信开发--如何存储并定时更新access_token
- object detection[YOLOv2]
- WCF 配置App.Config
- 用矩阵和待定系数法求数列的分析(复杂度log(n))
- Qt5编译oracle驱动教程