Java Parse Date parseDate(String datetime)

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

Description

parse Date

License

Open Source License

Declaration

public static Date parseDate(String datetime) 

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 final SimpleDateFormat FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    private static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd");

    public static Date parseDate(String datetime) {
        try {/*from  w ww. j a v a2 s .  co m*/
            return DATE_FORMAT.parse(datetime);
        } catch (ParseException e) {
            return new Date();
        }
    }

    public static Date parse(String datetime) {
        try {
            return FORMAT.parse(datetime);
        } catch (ParseException e) {
            return new Date();
        }
    }
}

Related

  1. parseDate(String dateString, SimpleDateFormat simpleDateFormat)
  2. parseDate(String dateString, String dateFormat)
  3. parseDate(String dateString, String format, TimeZone zone)
  4. parseDate(String dateString, String pattern)
  5. parseDate(String dateText)
  6. parseDate(String dateVal)
  7. parseDate(String dateValue)
  8. parseDate(String dateValue)
  9. parseDate(String dateValue, String strFormat)