Java SQL Date Create getLastDayOfMonth(java.sql.Date date)

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

Description

get Last Day Of Month

License

Open Source License

Parameter

Parameter Description
date Date

Return

Date

Declaration

public static java.sql.Date getLastDayOfMonth(java.sql.Date date) 

Method Source Code

//package com.java2s;
/**// w  ww.j  ava  2 s .  c  o  m
 * Copyright 2010 ZTEsoft Inc. All Rights Reserved.
 *
 * This software is the proprietary information of ZTEsoft Inc.
 * Use is subject to license terms.
 * 
 * $Tracker List
 * 
 * $TaskId: $ $Date: 9:24:36 AM (May 9, 2008) $comments: create 
 * $TaskId: $ $Date: 3:56:36 PM (SEP 13, 2010) $comments: upgrade jvm to jvm1.5 
 *  
 *  
 */

import java.util.Calendar;

public class Main {
    /**
     * @param date
     *            Date
     * @return Date
     */
    public static java.sql.Date getLastDayOfMonth(java.sql.Date date) {
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(date);
        int maxDay = calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
        calendar.set(Calendar.DAY_OF_MONTH, maxDay);
        calendar.set(Calendar.HOUR_OF_DAY, 23);
        calendar.set(Calendar.MINUTE, 59);
        calendar.set(Calendar.SECOND, 59);
        date.setTime(calendar.getTimeInMillis());
        return date;
    }
}

Related

  1. getLastDateOfQuarter()
  2. getLastDay(Date date)
  3. getLastDay(Date dt)
  4. getLastDay(java.util.Date dt)
  5. getLastDayofMonth(Date date1)
  6. getLastDayOfPreviousMonth(Date date, boolean isFormatDate)
  7. getLastSundayDate()
  8. getLongDate(String strDate)
  9. getSqlCurrentDate()