Here you can find the source of getLastDayOfMonth(java.sql.Date date)
Parameter | Description |
---|---|
date | Date |
public static java.sql.Date getLastDayOfMonth(java.sql.Date date)
//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; } }