Java Parse Date parseDate(String formatPattern, String dateStr)

Here you can find the source of parseDate(String formatPattern, String dateStr)

Description

parse Date

License

Open Source License

Declaration

public static Date parseDate(String formatPattern, String dateStr) throws ParseException 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.text.ParseException;
import java.text.SimpleDateFormat;

import java.util.Date;

public class Main {
    private static ThreadLocal<SimpleDateFormat> sdfLocal = new ThreadLocal<SimpleDateFormat>();

    public static Date parseDate(String formatPattern, String dateStr) throws ParseException {
        return getSdf(formatPattern).parse(dateStr);
    }//w w  w. j a v  a2 s.  c  o m

    public static SimpleDateFormat getSdf(String formatPattern) {
        SimpleDateFormat sdf = sdfLocal.get();
        if (sdf == null) {
            sdf = new SimpleDateFormat(formatPattern);
            sdfLocal.set(sdf);
        }
        return sdf;
    }
}

Related

  1. parseDate(String dateValue)
  2. parseDate(String dateValue, String strFormat)
  3. parseDate(String dttm)
  4. parseDate(String dttm)
  5. parseDate(String format, String value)
  6. parseDate(String formattedDate)
  7. parseDate(String gameDate)
  8. parseDate(String in)
  9. parseDate(String input)