Java Hour Format formatDateToEndDateTime(String strDate)

Here you can find the source of formatDateToEndDateTime(String strDate)

Description

format Date To End Date Time

License

Open Source License

Declaration

public static Date formatDateToEndDateTime(String strDate) 

Method Source Code

//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);
    }
}

Related

  1. formatDateTime12(String dateStr)
  2. formatDateTime24()
  3. formatDateTimeForSolr(Date d)
  4. formatDateTimeFull(Date dateTime)
  5. formatDateTimeStringForEquivalentCommand(final Date date)
  6. formatDateToHMSString(java.util.Date date)
  7. formatDateToHours(Date time)
  8. formatDateToStr(String format, Date date)
  9. formatDateToString(java.util.Date date, int format)