Here you can find the source of parseDate(String date, String format)
Parameter | Description |
---|---|
date | a parameter |
format | a parameter |
Parameter | Description |
---|---|
ParseException | an exception |
public static Date parseDate(String date, String format) throws ParseException
//package com.java2s; //License from project: Open Source License import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; import java.util.HashMap; import java.util.Map; public class Main { static Map<String, SimpleDateFormat> dateFormats = new HashMap<String, SimpleDateFormat>(); /**/* www. jav a2s.com*/ * Parse a date on a given format. * @param date * @param format * @return * @throws ParseException */ public static Date parseDate(String date, String format) throws ParseException { if (!dateFormats.containsKey(format)) { dateFormats.put(format, new SimpleDateFormat(format)); } return dateFormats.get(format).parse(date); } }