Calendar.getInstance().getActualMaximum(Calendar.DAY_OF_MONTH);

The above returns actual maximum for current month. For example it is February of leap year now, so it returns 29.

And to get last day as Date object:

Calendar cal = Calendar.getInstance();
cal.set(Calendar.DATE, cal.getActualMaximum(Calendar.DATE));

Date lastDayOfMonth = cal.getTime();

Once a Time I had a Scenario where I should display a Page with List of employees movement from Last Friday to this week Saturday if Saturday is over(you are in Sunday).If you are in any other day other than Saturday(Mon..Fri) then you should choose date of Last before Saturday to Friday.

The above would be made with the following

Image 1
Image 1

As you can see in the above diagram I have added two calendar.

In First I should Get Date between 15 to 21 since today date is this 28 and Saturday is not over
In Second I should Get Date between 22 to 28 since today date is this 30 nd Saturday is over

  java.util.Date dt    = new java.util.Date();
  SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
  String currentTime   = sdf.format(dt);
  Calendar cal         = Calendar.getInstance();

  int daysBackToSat = cal.get(Calendar.DAY_OF_WEEK);
  
  //Checks if this weeks friday is Over.in My Case 28 falls on Friday.
  //Returns 6 the below case is True so adds 13 to get before Saturday
  if(daysBackToSat < 7)
   daysBackToSat += 7; //6+7
 
  //Subtracting 13 Days for Last Saturday 
  //Since this Saturday is not Over
  cal.add(Calendar.DATE, daysBackToSat * -1);
  System.out.println("Start Date" + sdf.format(cal.getTime()));

  cal.add(Calendar.DATE, 6);
  System.out.println("End Date" + sdf.format(cal.getTime()));

Output Code
2013-06-15
2013-06-21

Below I have a List of Time to be added together

  List<String> arrTime = new ArrayList<String>();
  int hour      = 0;
  int minutes   = 0;
  int seconds   = 0;
  String Nmin   = null;
  String Nsec   = null;
  String result = null;

  arrTime.add("09:05:25");
  arrTime.add("09:30:15");
  arrTime.add("10:15:01");
  arrTime.add("08:19:49");
  arrTime.add("09:17:40");

  for (Iterator itr = arrTime.iterator(); itr.hasNext();) 
  {
    String Time = (String) itr.next();

    if (Time != null) 
    {
      String[] rowtime = Time.split(":");
      hour            += Integer.parseInt(rowtime[0]);
      minutes         += Integer.parseInt(rowtime[1]);
      seconds         += Integer.parseInt(rowtime[2]);
    }
  }

  hour    += minutes/60;
  minutes += seconds/60;

  minutes %= 60;
  seconds %= 60;

  if (minutes < 10)
   Nmin = "0" + String.valueOf(minutes);
  else
   Nmin = String.valueOf(minutes);
	 
  if (seconds < 10)
   Nsec = "0" + String.valueOf(seconds);
  else
   Nsec = String.valueOf(seconds);

  result = hour + ":" + Nmin + ":" + Nsec;
  
  System.out.println(result);

Output
46:28:10

Time to be Added together

TimeWorked
09:05:25
09:30:15
10:15:01
08:19:49
09:17:40

Code

int hour = 0;
int minute = 0;

for() {
    String[] rowtime= row[i].split(":");
    hour += Integer.parseInt(rowtime[0]);
    minute += Integer.parseInt(rowtime[1]);
}

hour += minute / 60;
minute %= 60;

String result = hour + ":" + minute

if(minute<10)
  Nmin = "0"+ String.valueOf(minute);
else
  Nmin = String.valueOf(minute);
		
 String result = hour + ":" + Nmin;