Java String to Date StringToDateByFormat(String dateStr, String formatStr)

Here you can find the source of StringToDateByFormat(String dateStr, String formatStr)

Description

String To Date By Format

License

Apache License

Declaration

public static Date StringToDateByFormat(String dateStr, String formatStr) 

Method Source Code


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

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

public class Main {

    public static Date StringToDateByFormat(String dateStr, String formatStr) {
        try {//from  w  w  w. j av a2s  .  c om
            SimpleDateFormat sdf = new SimpleDateFormat(formatStr);
            Date date = sdf.parse(dateStr);
            return date;
        } catch (Throwable t) {
            return null;
        }
    }
}

Related

  1. stringToDate(String vStr, String vPatten)
  2. StringToDate1(String strDate)
  3. stringToDate10(String date)
  4. stringToDateAndTime(final String dateAndTimeString)
  5. stringToDateByconf(String str, String formate)
  6. StringToDateByformat1(String time)
  7. stringToDateForIng(String date_str)
  8. StringToDateFormat(String str, String format)
  9. stringToDateInTimeZone(String time, String timeZone)