Here you can find the source of clearTimeFields(java.util.Date date)
Parameter | Description |
---|---|
date | a parameter |
public static java.util.Date clearTimeFields(java.util.Date date)
//package com.java2s; /*//from w w w .j av a2s. com * Copyright 2006-2008 The Kuali Foundation * * Licensed under the Educational Community License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.opensource.org/licenses/ecl2.php * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import java.util.Calendar; import java.util.GregorianCalendar; public class Main { /** * Convert the given java.sql.date into a java.sql.date of which all the time fields are set to 0. * * @param date * @return */ public static java.sql.Date clearTimeFields(java.sql.Date date) { Calendar timelessCal = new GregorianCalendar(); timelessCal.setTime(date); timelessCal.set(Calendar.HOUR_OF_DAY, 0); timelessCal.set(Calendar.MINUTE, 0); timelessCal.set(Calendar.SECOND, 0); timelessCal.set(Calendar.MILLISECOND, 0); return new java.sql.Date(timelessCal.getTimeInMillis()); } /** * Convert the given java.util.date into a java.util.date of which all the time fields are set to 0. * * @param date * @return */ public static java.util.Date clearTimeFields(java.util.Date date) { Calendar timelessCal = new GregorianCalendar(); timelessCal.setTime(date); timelessCal.set(Calendar.HOUR_OF_DAY, 0); timelessCal.set(Calendar.MINUTE, 0); timelessCal.set(Calendar.SECOND, 0); timelessCal.set(Calendar.MILLISECOND, 0); return new java.util.Date(timelessCal.getTimeInMillis()); } }