Here you can find the source of parseDate(String formatPattern, String dateStr)
public static Date parseDate(String formatPattern, String dateStr) throws ParseException
//package com.java2s; //License from project: Open Source License import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; public class Main { private static ThreadLocal<SimpleDateFormat> sdfLocal = new ThreadLocal<SimpleDateFormat>(); public static Date parseDate(String formatPattern, String dateStr) throws ParseException { return getSdf(formatPattern).parse(dateStr); }//w w w. j a v a2 s. c o m public static SimpleDateFormat getSdf(String formatPattern) { SimpleDateFormat sdf = sdfLocal.get(); if (sdf == null) { sdf = new SimpleDateFormat(formatPattern); sdfLocal.set(sdf); } return sdf; } }