Java Date from String convertToDate(String val)

Here you can find the source of convertToDate(String val)

Description

convert To Date

License

LGPL

Declaration

public static Date convertToDate(String val) throws ParseException 

Method Source Code


//package com.java2s;
/*/*from   www.j a  v a 2 s  . com*/
* Distributable under LGPL v3 license.
* See terms of license at https://github.com/Yunfeng/schotel/blob/master/LICENSE
*/

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

import java.util.Date;

public class Main {
    public static Date convertToDate(String val, String format) throws ParseException {
        SimpleDateFormat sdf = new SimpleDateFormat(format);
        return sdf.parse(val);
    }

    public static Date convertToDate(String val) throws ParseException {
        return convertToDate(val, "yyyy-MM-dd");
    }
}

Related

  1. convertToDate(String input)
  2. convertToDate(String str)
  3. convertToDate(String str, String format)
  4. convertToDate(String strDate, String format)
  5. convertToDate(String strDate, String format)
  6. convertToDate(String value)
  7. convertToDateTimeNoSec(String date)
  8. convertToDateTimeString(Date d1)
  9. convertToDateWithTimeString(Date date)