Java Date to Day getDayEnd(Date date)

Here you can find the source of getDayEnd(Date date)

Description

Calculates end of the day

License

Open Source License

Parameter

Parameter Description
date Date to use in calculation

Return

Date with hour set to 23 min and sec set to 59

Declaration

public static Date getDayEnd(Date date) 

Method Source Code


//package com.java2s;
/* /*  w w w . ja va  2  s . c o m*/
 * Copyright (C) 2014 Alex Pavlunenko <alexp at xpresstek.net>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

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

public class Main {
    /**
     * Calculates end of the day
     *
     * @param date Date to use in calculation
     * @return Date with hour set to 23 min and sec set to 59
     */
    public static Date getDayEnd(Date date) {
        Calendar end = new GregorianCalendar();
        end.setTime(date);
        end.set(Calendar.HOUR_OF_DAY, 23);
        end.set(Calendar.MINUTE, 59);
        end.set(Calendar.SECOND, 59);
        return end.getTime();
    }
}

Related

  1. getDay(java.util.Date date)
  2. getDay(String strDate)
  3. getDayBetween(Date startDate, Date endDate)
  4. getDayCount(java.util.Date _startDate, java.util.Date _endDate)
  5. getDayEnd(Date date)
  6. getDayEnd(Date date)
  7. getDayEnd(Date obj)
  8. getDayEnd(final Date date, TimeZone timezone)
  9. getDayFromDate(Date date)