Java Parse Date parseDate(String value, String pattern)

Here you can find the source of parseDate(String value, String pattern)

Description

parse Date

License

Open Source License

Declaration

public static java.util.Date parseDate(String value, String pattern) 

Method Source Code

//package com.java2s;

import java.text.*;

import java.util.TimeZone;

public class Main {
    public static java.util.Date parseDate(String value, String pattern) {
        try {/*from   w w w .  j av  a2 s.  com*/
            TimeZone tz = TimeZone.getDefault();
            String dateFormat = pattern;
            SimpleDateFormat sdf = new SimpleDateFormat(dateFormat);
            sdf.setTimeZone(tz);

            // Parse date
            java.util.Date parsed = null;

            parsed = sdf.parse(value);
            return parsed;
        } catch (ParseException e) {
            return null;
        }
    }
}

Related

  1. parseDate(String value)
  2. parseDate(String value)
  3. parseDate(String value)
  4. parseDate(String value, Class targetType, String... formats)
  5. parseDate(String value, String formater)
  6. parseDate2String(Date date)
  7. parseDate4UrlCreateTime(String dateStr)
  8. parseDateAllowNull(String date)
  9. parseDateAndGetLong(String date)