Java String to Date toDate(final String dateString, final String pattern)

Here you can find the source of toDate(final String dateString, final String pattern)

Description

to Date

License

LGPL

Declaration

public static final Date toDate(final String dateString, final String pattern) 

Method Source Code

//package com.java2s;

import java.text.SimpleDateFormat;
import java.util.Date;

public class Main {
    public static final Date toDate(final String dateString, final String pattern) {
        final SimpleDateFormat sdf = new SimpleDateFormat(pattern);
        try {//from   w  w  w.j a  v  a 2 s. co m
            return sdf.parse(dateString);
        } catch (final Exception e) {
            return null;
        }
    }
}

Related

  1. toDate(DateFormat format, String value)
  2. toDate(final Long date, final String pattern)
  3. toDate(final String _text, final String _dateFormat)
  4. toDate(final String date, final String time)
  5. toDate(final String dateString, final String format)
  6. toDate(int date, String timeFormat)
  7. toDate(long value, String format)
  8. toDate(Map filter, String field)
  9. toDate(Object v, String format, Date defaultValue)