Here you can find the source of parser(String strDate, String formatter)
Parameter | Description |
---|---|
formatter | like yyyy-MM-dd HH:mm:ss |
strDate | a parameter |
public static Date parser(String strDate, String formatter)
//package com.java2s; //License from project: Open Source License import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static Date parser(String strDate) { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); try {/*from ww w . ja va 2 s . c o m*/ return sdf.parse(strDate); } catch (Exception e) { return null; } } /** * @param formatter like yyyy-MM-dd HH:mm:ss * @param strDate * @return */ public static Date parser(String strDate, String formatter) { SimpleDateFormat sdf = new SimpleDateFormat(formatter); try { return sdf.parse(strDate); } catch (Exception e) { return null; } } }