Here you can find the source of DateFormat(String dateStr, String oldPattern, String newPattern)
public static String DateFormat(String dateStr, String oldPattern, String newPattern)
//package com.java2s; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static String DateFormat(String dateStr, String oldPattern, String newPattern) { SimpleDateFormat sdf = new SimpleDateFormat(oldPattern); Date date = null;//from w ww .j a va 2 s . c o m try { date = sdf.parse(dateStr); } catch (ParseException e) { e.printStackTrace(); return ""; } return new SimpleDateFormat(newPattern).format(date); } public static String DateFormat(Date date, String newPattern) { if (date == null) { return null; } SimpleDateFormat sdf = new SimpleDateFormat(newPattern); return sdf.format(date); } public static Date DateFormat(String dateStr, String pattern) throws ParseException { SimpleDateFormat sdf = new SimpleDateFormat(pattern); Date date = sdf.parse(dateStr); return date; } }