Java Day of Month getLastDayOfTheMonth(String dateOfString)

Here you can find the source of getLastDayOfTheMonth(String dateOfString)

Description

get Last Day Of The Month

License

Open Source License

Declaration

public static int getLastDayOfTheMonth(String dateOfString) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

public class Main {

    public static int getLastDayOfTheMonth(String dateOfString) {
        Calendar calendar = Calendar.getInstance();
        SimpleDateFormat yearMonthFormat = new SimpleDateFormat("yyyy-MM");
        Date date = null;//from   w  ww  . j a  v  a2  s  .  c  o  m
        try {
            date = yearMonthFormat.parse(dateOfString);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        calendar.setTime(date);
        final int lastDay = calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
        return lastDay;
    }
}

Related

  1. getLastDayOfMonth(int year, int month)
  2. getLastDayOfMonth(java.util.Date date)
  3. getLastDayOfMonth(String year, String month)
  4. getLastdayOfMonth(String year, String month)
  5. getLastDayOfMonth(String year, String month)
  6. getLastDayOfXMonth(Date date, String xMonth)
  7. getToDate(boolean invoiceSearchFromFirstDayOfMonth)
  8. getWeekOfFirstDayOfMonth(Date date)
  9. getWeekOfLastDayOfMonth(Date date)