Java TimeZone midnight(Date date, TimeZone tz)

Here you can find the source of midnight(Date date, TimeZone tz)

Description

Calculates midnight of the day in which date lies with respect to a time zone.

License

Apache License

Declaration

public static Date midnight(Date date, TimeZone tz) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

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

public class Main {
    /**//from  www .  jav a  2 s. com
     * Calculates midnight of the day in which date lies with respect
     * to a time zone.
     **/
    public static Date midnight(Date date, TimeZone tz) {
        Calendar cal = new GregorianCalendar(tz);
        cal.setTime(date);
        cal.set(Calendar.HOUR_OF_DAY, 0);
        cal.set(Calendar.MINUTE, 0);
        cal.set(Calendar.SECOND, 0);
        cal.set(Calendar.MILLISECOND, 0);
        return cal.getTime();
    }
}

Related

  1. getLocalTime( java.util.TimeZone localTimeZone, java.util.Date timestamp, java.util.TimeZone sourceTimeZone)
  2. getTimezoneDate(String stateCode)
  3. getTimeZoneOffset(Date d)
  4. getTimezoneOffsetInHours(Date date)
  5. hasTimeComponent(Date date, TimeZone timeZone)
  6. monthOfYear(Date referenceDate, int month, TimeZone timeZone)
  7. normalizeDate(Date date, TimeZone timeZone)
  8. startOfNextDay(final Date date, final TimeZone timeZone)
  9. startOfYear(Date referenceDate, TimeZone timeZone)