Java String to Date transformStringToDate(String dateString)

Here you can find the source of transformStringToDate(String dateString)

Description

transform String To Date

License

Open Source License

Declaration

public static Date transformStringToDate(String dateString) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

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

public class Main {

    public static Date transformStringToDate(String dateString) {
        Date date;/*from   w  w w  . java 2s  .c  o m*/
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        try {
            date = simpleDateFormat.parse(dateString);
        } catch (ParseException e) {
            e.printStackTrace();
            date = new Date();
        }
        return date;
    }
}

Related

  1. toDateTimeSSSString(long datetime)
  2. toDateTimeString(java.util.Date date)
  3. toDateTimeString(java.util.Date date)
  4. toDateWithFormatString(String date, String format)
  5. toDateWithTimezone(String dateTime, String pattern)
  6. translateToDate(String aDate, String aFormat)