Java tutorial
//package com.java2s; import java.text.ParseException; import java.text.SimpleDateFormat; public class Main { public static String formatDate(String date) { String returnDate = date; SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ", java.util.Locale.ENGLISH); SimpleDateFormat expectedFormat = new SimpleDateFormat("EE, MMM dd hh:mm a", java.util.Locale.ENGLISH); dateFormat.setLenient(true); try { returnDate = expectedFormat.format(dateFormat.parse(date)); } catch (ParseException e) { } if (returnDate == null || returnDate.length() == 0) { dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ", java.util.Locale.ENGLISH); dateFormat.setLenient(true); try { returnDate = expectedFormat.format(dateFormat.parse(date)); } catch (ParseException e) { } } return returnDate; } }