Switch to full style
Java2 codes,problems ,discussions and solutions are here
Post a reply

Want start and end date of a month from current date

Fri Jul 22, 2011 8:03 am

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

Code:
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.



Re: Want start and end date of a month from current date

Fri Jul 22, 2011 11:35 pm

Code:

   Calendar calendar 
Calendar.getInstance();
  
int yearpart 2010;
  
int monthPart 11;
  
int dateDay 1;
  
calendar.set(yearpartmonthPartdateDay);
  
int numOfDaysInMonth calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
  
System.out.println("Number of Days: " numOfDaysInMonth);
  
System.out.println("First Day of month: " calendar.getTime());
  
calendar.add(Calendar.DAY_OF_MONTHnumOfDaysInMonth-1);


  
System.out.println("Last Day of month: " calendar.getTime());
 


Post a reply
  Related Posts  to : Want start and end date of a month from current date
 Printing today+ current date with different format     -  
 Formatting a Date with date()     -  
 get next date by next day     -  
 Date in Java     -  
 String to sql.Date     -  
 date validation in asp     -  
 How To Increment Date In JSP?     -  
 date formatting in Java     -  
 Convert String to Date     -  
 Google indexing DATE     -  

Topic Tags

Java Time