How do I find out how many days there were in the last month? 30 or 31 [closed]

Closed. This question should be clarified or supplemented with details . Answers to it are not accepted at the moment.

Want to improve this question? Add more details and clarify the issue, by editing this message.

Closed 6 months ago.

Improve the question

I need to get the number of days in the last month. I know how to get the number of days in this month. Like this: int dayOfMnthMax = calendar.getActualMaximum(Calendar.DAY_OF_MONTH); But I need in the past month.

Author: Эникейщик, 2020-08-25

1 answers

That's what they suggest to do in the comments above ( Barmaley Red Star).

    Calendar calendar = Calendar.getInstance();
    calendar.add(Calendar.MONTH, -1);

    int max = calendar.getActualMaximum(Calendar.DAY_OF_MONTH);

Taking this into account, you can calculate anything

 4
Author: Aziz Umarov, 2020-08-25 10:57:45