Here you can find the source of getBeginEndTimeOfDay(Date day)
Parameter | Description |
---|---|
day | a parameter |
public static Date[] getBeginEndTimeOfDay(Date day)
//package com.java2s; /**/*from w ww . j a v a 2 s. c o m*/ * Project: CarTracServer * * File Created at Apr 6, 2013 * $id$ * * Copyright 2013, Shawn Chain (shawn.chain@gmail.com). * All rights reserved. * * Licensed under the Apache 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.apache.org/licenses/LICENSE-2.0 * * 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.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; import java.util.TimeZone; public class Main { public static Date[] getBeginEndTimeOfDay(String dayString) { try { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); Date begin = sdf.parse(dayString); return getBeginEndTimeOfDay(begin); } catch (Exception e) { // NOOP } return null; } /** * Returns the begin/end time of the given day * @param day * @return */ public static Date[] getBeginEndTimeOfDay(Date day) { Date begin, end; begin = day; Calendar cal = getCalendar(); cal.setTime(begin); cal.set(Calendar.HOUR, 23); cal.add(Calendar.MINUTE, 59); cal.add(Calendar.SECOND, 59); cal.set(Calendar.MILLISECOND, 999); end = cal.getTime(); return new Date[] { begin, end }; } public static Calendar getCalendar() { return Calendar.getInstance(TimeZone.getTimeZone("GMT+8")); } }