Java tutorial
//package com.java2s; import java.util.Date; public class Main { public static String formatDisplayDate(Date date, String inputFormat) { return formatDisplayDate(date.toString(), inputFormat); } public static String formatDisplayDate(String date, String inputFormat) { if (date.equals("")) return date; int length = inputFormat.length(); int yearStart = inputFormat.indexOf("y"); int yearEnd = inputFormat.lastIndexOf("y", length) + 1; int monthStart = inputFormat.indexOf("M"); int monthEnd = inputFormat.lastIndexOf("M", length) + 1; int dayStart = inputFormat.indexOf("d"); int dayEnd = inputFormat.lastIndexOf("d", length) + 1; String year = date.substring(yearStart, yearEnd); String month = date.substring(monthStart, monthEnd); String day = date.substring(dayStart, dayEnd); return month + "/" + day + "/" + year; } }