Here you can find the source of parseDate(String dateString, String pattern)
Parameter | Description |
---|---|
dateString | e.g. 2009-06-17T00:00:00.000 |
pattern | e.g. yyyy-mm-dd'T'HH:mm:ss.SSS |
Parameter | Description |
---|---|
Exception | ParseException, but also IllegalArgumentException |
public static long parseDate(String dateString, String pattern) throws Exception
//package com.java2s; //License from project: Open Source License import java.text.SimpleDateFormat; public class Main { /**//from ww w . jav a2 s . co m * Parse a date time String according to a supplied pattern. * @param dateString e.g. 2009-06-17T00:00:00.000 * @param pattern e.g. yyyy-mm-dd'T'HH:mm:ss.SSS * @return Returns the number of milliseconds since January 1, 1970, 00:00:00 GMT * @throws Exception ParseException, but also IllegalArgumentException */ public static long parseDate(String dateString, String pattern) throws Exception { return new SimpleDateFormat(pattern).parse(dateString).getTime(); } }