Here you can find the source of convertFormat(String src, String f1, String f2)
public static String convertFormat(String src, String f1, String f2)
//package com.java2s; import java.text.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static final String VN_DATE_FORMAT = "dd/MM/yyyy"; public static String convertFormat(String src, String f1, String f2) { Date date = stringToDate(src, f1); return dateToString(date, f2); }// w w w. j a v a2s.c om public static java.util.Date stringToDate(String src, String format) { try { src = src.trim(); if (format == null) format = VN_DATE_FORMAT; SimpleDateFormat ts = new SimpleDateFormat(format); return ts.parse(src); } catch (Exception e) { return null; } } public static String dateToString(Date date, String format) { if (format == null) format = VN_DATE_FORMAT; SimpleDateFormat ts = new SimpleDateFormat(format); return ts.format(date); } public static java.util.Date parse(String src) { try { return DateFormat.getDateInstance().parse(src); } catch (ParseException e) { return DateFormat.getInstance().getCalendar().getTime(); } } }