Java Parse Date parseDate(String date)

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

Description

parse Date

License

Apache License

Parameter

Parameter Description
date the string representation fo a date, formatted according to DateUtils.DATE_FORMAT

Return

the converted date object, or null in case of failure

Declaration

public static Date parseDate(String date) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;

public class Main {
    public static final String DATE_FORMAT = "dd/MM/yyyy";
    private static SimpleDateFormat dateFormat;

    /**//  w  w w.ja v  a2s.c om
     * @param date the string representation fo a date, formatted according to DateUtils.DATE_FORMAT
     * @return the converted date object, or null in case of failure
     */
    public static Date parseDate(String date) {
        checkDateFormat();

        try {
            return dateFormat.parse(date);
        } catch (ParseException e) {
            return null;
        }
    }

    private static void checkDateFormat() {
        if (dateFormat == null) {
            dateFormat = new SimpleDateFormat(DATE_FORMAT);
        }
    }
}

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)