Java Parse Date parseDate(String date)

Here you can find the source of parseDate(String date)

Description

parse Date

License

Open Source License

Declaration

public static Date parseDate(String date) 

Method Source Code


//package com.java2s;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;

import java.util.Date;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

public class Main {
    private static final Lock LOCK = new ReentrantLock();

    public static Date parseDate(String date) {
        return parseDate(date, "yyyy-MM-dd");

    }/* w w w.j a  va 2s.c o  m*/

    public static Date parseDate(String date, String pattern) {

        LOCK.lock();
        try {
            DateFormat fmt = new SimpleDateFormat(pattern);
            return fmt.parse(date);
        } catch (ParseException e) {
            e.printStackTrace();
            return null;
        } finally {
            LOCK.unlock();
        }
    }
}

Related

  1. parseDate(String date)
  2. parseDate(String date)
  3. parseDate(String date)
  4. parseDate(String date)
  5. parseDate(String date)
  6. parseDate(String date)
  7. parseDate(String date)
  8. parseDate(String date)
  9. parseDate(String date)