Here you can find the source of getDayDate(String date, String formatFormat)
public static Date getDayDate(String date, String formatFormat)
//package com.java2s; /*//from w w w .j av a 2s .c o m * Copyright 1998-2012 360buy.com All right reserved. This software is the confidential and proprietary information of * 360buy.com ("Confidential Information"). You shall not disclose such Confidential Information and shall use it only * in accordance with the terms of the license agreement you entered into with 360buy.com. */ import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; public class Main { public static Date getDayDate(String date, String formatFormat) { Calendar cal = Calendar.getInstance(); cal.setTime(strToDate(date, formatFormat)); cal.set(Calendar.HOUR_OF_DAY, 0); cal.set(Calendar.MINUTE, 0); cal.set(Calendar.SECOND, 0); return cal.getTime(); } public static Date strToDate(String dateStr, String formatStr) { Date date = null; if (dateStr != null && !"".equals(dateStr)) { SimpleDateFormat sdf = new SimpleDateFormat(formatStr); try { date = sdf.parse(dateStr); } catch (ParseException e) { e.printStackTrace(); } } return date; } }