How to get the time of last month through LocalDate in java8
大家讲道理2017-06-14 10:52:53
0
2
996
As the title says, LocalDate has many methods about next. How can I get the time of last month through Localdate? It can also be a certain day of last month. Then I can intercept the string, and finally it will be like "2017-06"
Listing so many methods is not to ask you to memorize them by rote, but to have an impression in your mind and know what common methods are there and what they can do. To sum up, there are four commonly used methods in the LocalDate class: obtaining date information, modifying date information, addition and subtraction operations, and comparison between date objects. After remembering these, you can refer to them later at work without having to reinvent the wheel yourself.
There is a
minusMonths
method in the API. If you subtract one month, it means the previous month.Click to view the API
Listing so many methods is not to ask you to memorize them by rote, but to have an impression in your mind and know what common methods are there and what they can do. To sum up, there are four commonly used methods in the LocalDate class: obtaining date information, modifying date information, addition and subtraction operations, and comparison between date objects. After remembering these, you can refer to them later at work without having to reinvent the wheel yourself.