Java Date Previous previousDayLastHour(final Date pDate)

Here you can find the source of previousDayLastHour(final Date pDate)

Description

Return last time of previous day for between comparison.

License

CeCILL license

Parameter

Parameter Description
pDate the date

Return

true, if is date valide

Declaration

public static Date previousDayLastHour(final Date pDate) 

Method Source Code

//package com.java2s;
/**/*from   w w w  . j a v a  2 s  .  co  m*/
 * Copyright ou ? ou Copr. Minist?re de l'Europe et des Affaires ?trang?res (2017)
 * <p/>
 * pole-architecture.dga-dsi-psi@diplomatie.gouv.fr
 * <p/>
 * Ce logiciel est un programme informatique servant ? faciliter la cr?ation d'applications Web conform?ment
 * aux r?f?rentiels g?n?raux fran?ais : RGI, RGS et RGAA
 * <p/>
 * Ce logiciel est r?gi par la licence CeCILL soumise au droit fran?ais et respectant les principes de
 * diffusion des logiciels libres. Vous pouvez utiliser, modifier et/ou redistribuer ce programme sous les
 * conditions de la licence CeCILL telle que diffus?e par le CEA, le CNRS et l'INRIA sur le site
 * "http://www.cecill.info".
 * <p/>
 * En contrepartie de l'accessibilit? au code source et des droits de copie, de modification et de
 * redistribution accord?s par cette licence, il n'est offert aux utilisateurs qu'une garantie limit?e. Pour
 * les m?mes raisons, seule une responsabilit? restreinte p?se sur l'auteur du programme, le titulaire des
 * droits patrimoniaux et les conc?dants successifs.
 * <p/>
 * A cet ?gard l'attention de l'utilisateur est attir?e sur les risques associ?s au chargement, ?
 * l'utilisation, ? la modification et/ou au d?veloppement et ? la reproduction du logiciel par l'utilisateur
 * ?tant donn? sa sp?cificit? de logiciel libre, qui peut le rendre complexe ? manipuler et qui le r?serve
 * donc ? des d?veloppeurs et des professionnels avertis poss?dant des connaissances informatiques
 * approfondies. Les utilisateurs sont donc invit?s ? charger et tester l'ad?quation du logiciel ? leurs
 * besoins dans des conditions permettant d'assurer la s?curit? de leurs syst?mes et ou de leurs donn?es et,
 * plus g?n?ralement, ? l'utiliser et l'exploiter dans les m?mes conditions de s?curit?.
 * <p/>
 * Le fait que vous puissiez acc?der ? cet en-t?te signifie que vous avez pris connaissance de la licence
 * CeCILL, et que vous en avez accept? les termes.
 * <p/>
 * <p/>
 * Copyright or ? or Copr. Ministry for Europe and Foreign Affairs (2017)
 * <p/>
 * pole-architecture.dga-dsi-psi@diplomatie.gouv.fr
 * <p/>
 * This software is a computer program whose purpose is to facilitate creation of web application in
 * accordance with french general repositories : RGI, RGS and RGAA.
 * <p/>
 * This software is governed by the CeCILL license under French law and abiding by the rules of distribution
 * of free software. You can use, modify and/ or redistribute the software under the terms of the CeCILL
 * license as circulated by CEA, CNRS and INRIA at the following URL "http://www.cecill.info".
 * <p/>
 * As a counterpart to the access to the source code and rights to copy, modify and redistribute granted by
 * the license, users are provided only with a limited warranty and the software's author, the holder of the
 * economic rights, and the successive licensors have only limited liability.
 * <p/>
 * In this respect, the user's attention is drawn to the risks associated with loading, using, modifying
 * and/or developing or reproducing the software by the user in light of its specific status of free software,
 * that may mean that it is complicated to manipulate, and that also therefore means that it is reserved for
 * developers and experienced professionals having in-depth computer knowledge. Users are therefore encouraged
 * to load and test the software's suitability as regards their requirements in conditions enabling the
 * security of their systems and/or data to be ensured and, more generally, to use and operate it in the same
 * conditions as regards security.
 * <p/>
 * The fact that you are presently reading this means that you have had knowledge of the CeCILL license and
 * that you accept its terms.
 *
 */

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

public class Main {
    /**
     * Return last time of previous day for between comparison.
     *
     * @param pDate
     *            the date
     * @return true, if is date valide
     */
    public static Date previousDayLastHour(final Date pDate) {

        final Calendar c = Calendar.getInstance();
        c.setTime(pDate);
        c.set(Calendar.HOUR_OF_DAY, c.getMaximum(Calendar.HOUR_OF_DAY));
        c.set(Calendar.MINUTE, c.getMaximum(Calendar.MINUTE));
        c.set(Calendar.SECOND, c.getMaximum(Calendar.SECOND));
        c.set(Calendar.MILLISECOND, c.getMaximum(Calendar.MILLISECOND));
        c.add(Calendar.DATE, -1);

        return c.getTime();
    }
}

Related

  1. getPreviousQuarterStartDate(Date dt)
  2. getPreviuosRoundMonth(Date baseDate)
  3. previousDay(Date date)
  4. previousDay(long date)
  5. previousDay(long date)