Convert String Date to String date different format

public static String getFormatedDate(String strDate) {
try {
//create SimpleDateFormat object with source string date format
SimpleDateFormat sdfSource = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
//parse the string into Date object
Date date = sdfSource.parse(strDate);
//create SimpleDateFormat object with desired date format
SimpleDateFormat sdfDestination = new SimpleDateFormat("dd-MMM-yyyy");
//parse the date into another format
strDate = sdfDestination.format(date);
System.out.println("Date is converted from dd-MMM-yyyy format to yyyy-MM-dd'T'HH:mm:ss");
System.out.println("Converted date is : " + strDate);
} catch (ParseException pe) {
System.out.println("Parse Exception : " + pe);
}
return strDate;
}

Comments