Java Day Start startOfDay(Date inDate, TimeZone timeZone)

Here you can find the source of startOfDay(Date inDate, TimeZone timeZone)

Description

Calculate the start of day date time (i.e.

License

Open Source License

Parameter

Parameter Description
inDate The date to cacluate start of day from.

Return

The Date at the start of the day.

Declaration

public static Date startOfDay(Date inDate, TimeZone timeZone) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

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

public class Main {
    /**//from w w  w .j av  a  2 s. c  o m
     * Calculate the start of day date time (i.e. at 00:00) for a given date.
     * 
     * @param inDate The date to cacluate start of day from.
     * @return The Date at the start of the day.
     */
    public static Date startOfDay(Date inDate, TimeZone timeZone) {
        GregorianCalendar c1 = new GregorianCalendar();
        c1.setTimeZone(timeZone);
        c1.setTime(inDate);
        GregorianCalendar c2 = new GregorianCalendar(c1.get(Calendar.YEAR), c1.get(Calendar.MONTH),
                c1.get(Calendar.DATE));
        c2.setTimeZone(timeZone);
        return c2.getTime();
    }
}

Related

  1. startOfDay(Date aDate)
  2. startOfDay(Date aDate)
  3. startOfDay(Date date)
  4. startOfDay(Date date)
  5. startOfDay(Date dateInst)
  6. startOfDay(Date value)
  7. startOfDay(final Date date)
  8. startOfDay(final Date date)
  9. startOfDayInMillis(long date)