/**
* Format a time from a given format to given target format
*
* @param inputFormat
* @param inputTimeStamp
* @param outputFormat
* @return
* @throws ParseException
*/
private static String TimeStampConverter(final String inputFormat,
String inputTimeStamp, final String outputFormat)
throws ParseException {
return new SimpleDateFormat(outputFormat).format(new SimpleDateFormat(
inputFormat).parse(inputTimeStamp));
}
Sample Usage is as Following:
try {
String inputTimeStamp = "Tue Feb 05 13:59:44 IST 2013";
final String inputFormat = "EEE MMM dd HH:mm:ss z yyyy";
final String outputFormat = "yyyy.MM.dd GGG hh:mm aaa";
System.out.println(TimeStampConverter(inputFormat, inputTimeStamp,
outputFormat));
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}