Java Parse Date parseDate(String format, String value)

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

Description

parse Date

License

Open Source License

Declaration

public static synchronized Date parseDate(String format, String value) 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;
import java.util.HashMap;
import java.util.Map;

public class Main {
    private static final Map<String, SimpleDateFormat> formatters = new HashMap<String, SimpleDateFormat>();

    public static synchronized Date parseDate(String format, String value) throws ParseException {
        SimpleDateFormat df = getDateFormat(format);
        return df.parse(value);
    }//from  w ww  .j  a  v a  2 s  . c  om

    private static SimpleDateFormat getDateFormat(String format) {
        SimpleDateFormat df = (SimpleDateFormat) formatters.get(format);
        if (df == null) {
            df = new SimpleDateFormat(format);
            formatters.put(format, df);
        }
        return df;
    }
}

Related

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