Java Day Of Year getMaxDayOfYearMonth(String date)

Here you can find the source of getMaxDayOfYearMonth(String date)

Description

get Max Day Of Year Month

License

Open Source License

Declaration

public static String getMaxDayOfYearMonth(String date) 

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 String getMaxDayOfYearMonth(String date) {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");
        try {/*from w  ww.ja va 2s  . co m*/
            Date d = sdf.parse(date);
            Calendar calendar = Calendar.getInstance();
            calendar.setTime(d);
            int lastDayNum = calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
            date = date + "-" + lastDayNum;
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return date;
    }
}

Related

  1. getEndTimeOfYear(int year)
  2. getFirstDayOfTheYear(int year)
  3. getFirstDayOfYear(int year)
  4. getLastYearOfToday()
  5. getMaxDayByYearMonth(String ym)
  6. getMaxWeekNumOfYear(int year)