Java TimeZone getDateWithoutTimeZone(Date date)

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

Description

Returns a Calendar without time zone & time

License

Open Source License

Parameter

Parameter Description
date The Date to convert to Calendar

Return

the Calendar

Declaration

public static Calendar getDateWithoutTimeZone(Date date) 

Method Source Code

//package com.java2s;

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

public class Main {
    /**/*from w w w.j av  a2s . c  om*/
     * Returns a Calendar without time zone & time
     * @param date The Date to convert to Calendar
     * @return the Calendar
     */
    public static Calendar getDateWithoutTimeZone(Date date) {
        if (date == null) {
            return null;
        }
        Calendar cal = getCalendarWithoutTimeZone(date);
        cal.clear(Calendar.ZONE_OFFSET);
        cal.set(Calendar.HOUR, 0);
        cal.set(Calendar.MINUTE, 0);
        cal.set(Calendar.SECOND, 0);
        cal.set(Calendar.MILLISECOND, 0);
        return cal;
    }

    /**
     * Returns a Calendar with no time zone
     * @param date The Date to convert to Calendar
     * @return the Calendar
     */
    public static Calendar getCalendarWithoutTimeZone(Date date) {
        if (date == null) {
            return null;
        }
        Calendar cal = Calendar.getInstance();
        cal.setTime(date);
        cal.clear(Calendar.ZONE_OFFSET);
        return cal;
    }
}

Related

  1. extractTimeZone(String strdate, Date thedate)
  2. getDateAtTimeZone(Date when, TimeZone from, TimeZone to)
  3. getDateAttributes(long millisec, TimeZone tz, boolean showNumber)
  4. getDateBoxValue(TimeZone zone, Date date)
  5. getDateValue(TimeZone zone, Long dateBoxValue, Long timeBoxValue)
  6. getExcelSerialDayNumber(Date date, Locale locale, TimeZone timeZone)
  7. getLocalTime( java.util.TimeZone localTimeZone, java.util.Date timestamp, java.util.TimeZone sourceTimeZone)
  8. getTimezoneDate(String stateCode)
  9. getTimeZoneOffset(Date d)