Here you can find the source of formatDateToEndDateTime(String strDate)
public static Date formatDateToEndDateTime(String strDate)
//package com.java2s; //License from project: Open Source License import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static final String LONG_DATE_TIME_PATTERN = "yyyy-MM-dd HH:mm:ss"; public static Date formatDateToEndDateTime(String strDate) { java.util.Date date = null; try {//from w w w.ja v a2 s . c o m date = convertStringToDate(LONG_DATE_TIME_PATTERN, strDate + " 23:59:59"); } catch (ParseException e) { e.printStackTrace(); } return date; } /** * This method generates a string representation of a date/time in the * format you specify on input * * @param aMask * the date pattern the string is in * @param strDate * a string representation of a date * @return a converted Date object * @see java.text.SimpleDateFormat * @throws ParseException * when String doesn't match the expected format */ public static Date convertStringToDate(String aMask, String strDate) throws ParseException { SimpleDateFormat df; Date date; df = new SimpleDateFormat(aMask); try { date = df.parse(strDate); } catch (ParseException pe) { // log.error("ParseException: " + pe); throw new ParseException(pe.getMessage(), pe.getErrorOffset()); } return (date); } }