Java SQL Date Month getMaxDayInMonth(java.sql.Date date)

Here you can find the source of getMaxDayInMonth(java.sql.Date date)

Description

get Max Day In Month

License

Apache License

Declaration

public static Timestamp getMaxDayInMonth(java.sql.Date date) 

Method Source Code

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

import java.sql.Timestamp;

import java.util.Calendar;

public class Main {

    public static Timestamp getMaxDayInMonth(java.sql.Date date) {

        Calendar cale = Calendar.getInstance();
        cale.setTime(date);/*  ww  w  . jav a2  s  . co  m*/
        cale.set(Calendar.DAY_OF_MONTH,
                cale.getActualMaximum(Calendar.DAY_OF_MONTH));
        java.sql.Date newDate = new java.sql.Date(cale.getTimeInMillis());

        cale = null;
        return Timestamp.valueOf(newDate.toString() + " 23:59:59.999");
    }
}

Related

  1. getFirstDayOfNextMonth(Date date, boolean isFormatDate)
  2. getMinDayInMonth(java.sql.Date date)
  3. getMonth(Date date)
  4. getMonth(final java.sql.Date date)
  5. getMonthAmount(java.sql.Date _startDate, java.sql.Date _endDate)