public static String getDateFormat(final String date, final String datePattern,
    final String formatPattern) {

    Date parsedDate = getDateFromString(date, datePattern);
    SimpleDateFormat simpleDateFormat = buildDateFormat(formatPattern);
    return simpleDateFormat.format(parsedDate);
  }
public static String getDateFormat ( final String date , final String datePattern , final String formatPattern ) { Date parsedDate = getDateFromString ( date , datePattern ) ; SimpleDateFormat simpleDateFormat = buildDateFormat ( formatPattern ) ; return simpleDateFormat . format ( parsedDate ) ; }
Format date from given date string and date pattern by format pattern.<br>
<p>
e.g:<br>
date: '2012-12-21 13:14:20'<br>
datePattern: 'yyyy-MM-dd'<br>
formatPattern: 'yyyy-MM-dd 23:59:59'<br>
result: "2012-12-21 23:59:59"
</p>

@param date date string to be handled.
@param datePattern pattern to handle date string to date object.
@param formatPattern pattern use to format given date.
@return format date from given date string and date pattern by format
pattern.
@throws DateException