Java Parse Date parseDate(String s)

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

Description

Parses text in 'YYYY-MM-DD' format to produce a date.

License

Open Source License

Parameter

Parameter Description
s the text

Exception

Parameter Description
ParseException an exception

Return

Date

Declaration

static public Date parseDate(String s) 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;

public class Main {
    /**/*w  w w  .  j av a 2  s.  co m*/
     * format pattern : yyyy-MM-dd
     */
    public static final SimpleDateFormat FORMAT_YYYY_MM_DD = new SimpleDateFormat("yyyy-MM-dd");

    /**
     * Parses text in 'YYYY-MM-DD' format to produce a date.
     * 
     * @param s
     *            the text
     * @return Date
     * @throws ParseException
     */
    static public Date parseDate(String s) throws ParseException {
        return FORMAT_YYYY_MM_DD.parse(s);
    }

    static public Date parseDate(String s, String f) throws ParseException {
        SimpleDateFormat format = new SimpleDateFormat(f);
        return format.parse(s);
    }
}

Related

  1. parseDate(String partten, String datatime)
  2. parseDate(String representedValue)
  3. parseDate(String s)
  4. parseDate(String s)
  5. parseDate(String s)
  6. parseDate(String s)
  7. parseDate(String s)
  8. parseDate(String s)
  9. parseDate(String s)