Java tutorial
//package com.java2s; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Locale; public class Main { public static String getJobDateFormat(String strDate, String inputFormat) { String formatDate = ""; String dayFormat[] = strDate.split("-"); int day = Integer.parseInt(dayFormat[0]); try { String dayNumberSuffix = getDayNumberSuffix(day); SimpleDateFormat inputDateFormat = new SimpleDateFormat(inputFormat, Locale.US); Date date = inputDateFormat.parse(strDate); SimpleDateFormat outputDateFormat = new SimpleDateFormat(" d'" + dayNumberSuffix + "' MMMM yyyy", Locale.US); formatDate = outputDateFormat.format(date); } catch (ParseException e) { e.printStackTrace(); } return formatDate; } private static String getDayNumberSuffix(int day) { if (day >= 11 && day <= 13) { return "th"; } switch (day % 10) { case 1: return "st"; case 2: return "nd"; case 3: return "rd"; default: return "th"; } } }