Here you can find the source of parse(String s, String formatPattern)
public static Date parse(String s, String formatPattern)
//package com.java2s; //License from project: Apache License import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; public class Main { private static final String LEGACY_FORMAT = "MM/dd/yyyy HH:mm aa"; public static Date parse(String s, String formatPattern) { try {/*from w w w . java 2 s. c om*/ return new SimpleDateFormat(formatPattern).parse(s); } catch (ParseException e) { throw new RuntimeException("could not parse date: " + s + " LEGACY_FORMAT = " + new SimpleDateFormat(LEGACY_FORMAT).toPattern(), e); } } }