Java Parse Date Pattern YYYY parser(String strDate, String formatter)

Here you can find the source of parser(String strDate, String formatter)

Description

parser

License

Open Source License

Parameter

Parameter Description
formatter like yyyy-MM-dd HH:mm:ss
strDate a parameter

Declaration

public static Date parser(String strDate, String formatter) 

Method Source Code

//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;
        }
    }
}

Related

  1. parseMySQLDateTime(String date)
  2. parseNanos(final String date)
  3. parseOpenMrsDate(String date)
  4. parseOpenMrsDate(String date)
  5. parsePurgeDateString(String str)
  6. parserDate(String str)
  7. parseRegExcelNumber(String number)
  8. parseResponseDate(String date)
  9. parseRoundTripDateString(String roundTripString)