Here you can find the source of formatEndTime(String datePre)
public static Date formatEndTime(String datePre)
//package com.java2s; //License from project: Apache License import java.text.SimpleDateFormat; import java.util.Date; public class Main { private final static String TIME_FORMAT = "yyyy-MM-dd HH:mm:ss"; public static Date formatEndTime(String datePre) { if (datePre == null) return null; String dateStr = addDateEndfix(datePre); return getFormatDateTime(dateStr); }//from w w w. j av a2 s. co m public static String addDateEndfix(String datestring) { if ((datestring == null) || datestring.equals("")) { return null; } return datestring + " 23:59:59"; } public static String getFormatDateTime(java.util.Date currDate) { return getFormatDateTime(currDate, TIME_FORMAT); } public static Date getFormatDateTime(String currDate) { return getFormatDateTime(currDate, TIME_FORMAT); } public static String getFormatDateTime(java.util.Date currDate, String format) { SimpleDateFormat dtFormatdB = null; try { dtFormatdB = new SimpleDateFormat(format); return dtFormatdB.format(currDate); } catch (Exception e) { dtFormatdB = new SimpleDateFormat(TIME_FORMAT); try { return dtFormatdB.format(currDate); } catch (Exception ex) { } } return null; } public static Date getFormatDateTime(String currDate, String format) { SimpleDateFormat dtFormatdB = null; try { dtFormatdB = new SimpleDateFormat(format); return dtFormatdB.parse(currDate); } catch (Exception e) { dtFormatdB = new SimpleDateFormat(TIME_FORMAT); try { return dtFormatdB.parse(currDate); } catch (Exception ex) { } } return null; } }