localdateime获取天
时间: 2024-02-20 19:00:26 浏览: 27
你可以使用Java 8中的`LocalDateTime`类的`getDayOfMonth()`方法来获取一个日期时间对象的天。例如,以下代码将获取当前日期时间的天:
```java
LocalDateTime now = LocalDateTime.now();
int dayOfMonth = now.getDayOfMonth();
System.out.println("Today is the " + dayOfMonth + "th day of the month.");
```
输出结果可能类似于:"Today is the 23th day of the month."。
相关推荐
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![7z](https://img-home.csdnimg.cn/images/20210720083312.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)