Java String to Date toDate(String string, String format)

Here you can find the source of toDate(String string, String format)

Description

to Date

License

Open Source License

Declaration

public static Date toDate(String string, String format) 

Method Source Code

//package com.java2s;

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

import java.util.Date;

public class Main {
    public static Date toDate(String string, String format) {
        DateFormat dateFormat = new SimpleDateFormat(format);
        dateFormat.setLenient(true);/*  w ww  . j  a va  2  s .  com*/
        Date d;
        try {
            d = dateFormat.parse(string);
        } catch (ParseException pe) {
            throw new IllegalArgumentException(pe);
        }
        return d;
    }
}

Related

  1. toDate(String str)
  2. toDate(String str)
  3. toDate(String strDate)
  4. toDate(String strDate)
  5. toDate(String string)
  6. toDate(String time)
  7. toDate(String time)
  8. toDate(String ts)
  9. toDate(String value)