Java String to Date stringToDate(String time, String format)

Here you can find the source of stringToDate(String time, String format)

Description

string To Date

License

Apache License

Declaration

public static Date stringToDate(String time, String format) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

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

import java.util.Date;

public class Main {

    public static Date stringToDate(String time, String format) {
        try {//from w w  w. j  a  v a  2  s  .  c o m
            SimpleDateFormat sdf = new SimpleDateFormat(format);
            return sdf.parse(time);
        } catch (ParseException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            return null;
        }
    }

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

Related

  1. stringToDate(String strDate, String strFormat)
  2. stringToDate(String string)
  3. stringToDate(String string, String format)
  4. stringToDate(String text)
  5. StringToDate(String thisdate, Locale locale)
  6. stringToDate(String vStr, String vPatten)
  7. StringToDate1(String strDate)
  8. stringToDate10(String date)
  9. stringToDateAndTime(final String dateAndTimeString)