Here you can find the source of parseDate(String date, String pattern)
Parameter | Description |
---|---|
date | a parameter |
pattern | a parameter |
Parameter | Description |
---|---|
Exception | an exception |
public static Date parseDate(String date, String pattern) throws Exception
//package com.java2s; /**//from w w w .ja v a 2s. c o m * * Methods Descrip:Converts a line of text into an array of lower case words * using a BreakIterator.wordInstance(). * <p> * * This method is under the Jive Open Source Software License and was * written by Mark Imbriaco. * * @param text * a String of text to convert into an array of words * @return text broken up into an array of words. * */ import java.util.Date; public class Main { /** * * Methods Descrip: * * @param date * @param pattern * @return * @throws Exception * */ public static Date parseDate(String date, String pattern) throws Exception { Date returnDate = null; if (pattern == null || pattern.equals("") || pattern.equals("null")) { pattern = "yyyy-MM-dd"; } java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat(pattern); try { returnDate = sdf.parse(date); } catch (Exception e) { throw e; } return returnDate; } }