Java Date Create createInitialDateQuery(final Date date)

Here you can find the source of createInitialDateQuery(final Date date)

Description

Convert Date to same Date with first minute of day.

License

Open Source License

Parameter

Parameter Description
date a parameter

Declaration

public static Date createInitialDateQuery(final Date date) 

Method Source Code

//package com.java2s;
/**/*from ww w  .j  a v a  2s.c o m*/
 * Vulpe Framework - Quick and Smart ;)
 * Copyright (C) 2011 Active Thread
 *
 * Este programa ? software livre; voc? pode redistribu?-lo e/ou
 * modific?-lo sob os termos da Licen?a P?blica Geral GNU, conforme
 * publicada pela Free Software Foundation; tanto a vers?o 2 da
 * Licen?a como (a seu crit?rio) qualquer vers?o mais nova.
 *
 * Este programa ? distribu?do na expectativa de ser ?til, mas SEM
 * QUALQUER GARANTIA; sem mesmo a garantia impl?cita de
 * COMERCIALIZA??O ou de ADEQUA??O A QUALQUER PROP?SITO EM
 * PARTICULAR. Consulte a Licen?a P?blica Geral GNU para obter mais
 * detalhes.
 *
 * Voc? deve ter recebido uma c?pia da Licen?a P?blica Geral GNU
 * junto com este programa; se n?o, escreva para a Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
 */

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

public class Main {
    /**
     * Convert Date to same Date with first minute of day. Example: Input:
     * 01/01/2005 Output: 01/01/2005 00:00:00
     *
     * @param date
     * @return
     */
    public static Date createInitialDateQuery(final Date date) {
        final Calendar calendar = new GregorianCalendar();
        calendar.setTime(date);
        calendar.set(Calendar.HOUR_OF_DAY, 0);
        calendar.set(Calendar.MINUTE, 0);
        calendar.set(Calendar.SECOND, 0);
        calendar.set(Calendar.MILLISECOND, 0);
        return calendar.getTime();
    }
}

Related

  1. createDateString(long startDate, long endDate)
  2. createDateTime(Date date, Date time)
  3. createDateTime(int year, int month, int day, int hour, int minute, int second, String timezone)
  4. createFutureDate()
  5. createFutureDate(int min)
  6. createTime(Date date)
  7. date()
  8. date(Date d)
  9. date(final int year, final int month, final int dayOfMonth)