Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Want to get the start and end date of a month from a particular date

Tags:

java

I m having a code which gives date of a particular event like :

String date=date1.substring(3,5)+"/"+date1.substring(0,2)+"/"+date1.substring(6,10);

I want the start date and end date of the month of which the above date belongs to..

Kindly help.

like image 926
sagarg Avatar asked Oct 15 '25 16:10

sagarg


1 Answers

Use Calendar.getActualMaximum()

To get the max date of the month

cal.getActualMaximum(Calendar.DAY_OF_MONTH)

and for minimum

cal.getActualMinimum(Calendar.DAY_OF_MONTH)

Note : cal is an instance of Calendar

like image 187
jmj Avatar answered Oct 17 '25 04:10

jmj



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!