Java Parse Date parseDate(String dateString)

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

Description

Method description

License

Open Source License

Parameter

Parameter Description
dateString a parameter

Exception

Parameter Description
ParseException an exception

Declaration

public static Date parseDate(String dateString) throws ParseException 

Method Source Code


//package com.java2s;

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

import java.util.Date;

import java.util.TimeZone;

public class Main {
    /** Field description */
    public static final String DATE_PATTERN = "yyyy-MM-dd HH-mm-ss";

    /**//from   w w w . j a v a 2  s  .c  o m
     * Method description
     *
     *
     * @param dateString
     * @param tz
     *
     * @return
     *
     * @throws ParseException
     */
    public static Date parseDate(String dateString, TimeZone tz) throws ParseException {
        SimpleDateFormat sdf = new SimpleDateFormat(DATE_PATTERN);

        if (tz != null) {
            sdf.setTimeZone(tz);
        }

        return sdf.parse(dateString);
    }

    /**
     * Method description
     *
     *
     * @param dateString
     *
     * @return
     *
     * @throws ParseException
     */
    public static Date parseDate(String dateString) throws ParseException {
        return parseDate(dateString, null);
    }
}

Related

  1. parseDate(String dateString)
  2. parseDate(String dateString)
  3. parseDate(String dateString)
  4. parseDate(String dateString)
  5. parseDate(String dateString)
  6. parseDate(String dateString, Locale locale)
  7. parseDate(String dateString, SimpleDateFormat simpleDateFormat)
  8. parseDate(String dateString, String dateFormat)
  9. parseDate(String dateString, String format, TimeZone zone)