Java Day Of Year getMaxDayByYearMonth(String ym)

Here you can find the source of getMaxDayByYearMonth(String ym)

Description

get Max Day By Year Month

License

Apache License

Declaration

public static int getMaxDayByYearMonth(String ym) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.text.ParseException;
import java.text.SimpleDateFormat;

import java.util.Calendar;

import java.util.Date;
import java.util.GregorianCalendar;

public class Main {

    public static int getMaxDayByYearMonth(String ym) {
        int day = 0;
        try {/*from  w  ww .  j  a v a2  s  .c o  m*/
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");
            Calendar calendar = new GregorianCalendar();
            Date date = sdf.parse(ym);
            calendar.setTime(date);
            day = calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
        } catch (ParseException e) {
            day = 0;
        }
        return day;
    }
}

Related

  1. getDaysOfYear(int year)
  2. getEndTimeOfYear(int year)
  3. getFirstDayOfTheYear(int year)
  4. getFirstDayOfYear(int year)
  5. getLastYearOfToday()
  6. getMaxDayOfYearMonth(String date)
  7. getMaxWeekNumOfYear(int year)