Java String to Date stringToDateTime(String stringDate, String format)

Here you can find the source of stringToDateTime(String stringDate, String format)

Description

string To Date Time

License

Open Source License

Declaration

public static final Date stringToDateTime(String stringDate,
        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 final Date stringToDateTime(String stringDate,
            String format) {//from   w  w w.j  a  va 2  s .  c  o  m
        if (stringDate == null) {
            return null;
        }

        try {
            return getFormat(format).parse(stringDate);
        } catch (ParseException e) {
            throw new RuntimeException(e);
        }
    }

    public static final DateFormat getFormat(String format) {
        return new SimpleDateFormat(format);
    }
}

Related

  1. stringToDateInTimeZone(String time, String timeZone)
  2. stringToDateMetaData(String dateString)
  3. stringToDateTemporalCoverage(String dateString)
  4. stringToDatetime(String str, String format)
  5. stringToDatetime(String string)
  6. stringToDateWithFormat(String stringToConvert, String dateFormat)
  7. strMSShortToDate(String str_date)
  8. strToDate(final String str)
  9. strToDate(String _date, String format)