Java String to Time string2DateTime(String stringDate)

Here you can find the source of string2DateTime(String stringDate)

Description

string Date Time

License

Apache License

Declaration

public static final Date string2DateTime(String stringDate) throws ParseException 

Method Source Code


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

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

import java.util.Date;

public class Main {
    public static final String simple = "yyyy-MM-dd HH:mm:ss";

    public static final Date string2DateTime(String stringDate) throws ParseException {
        if (stringDate == null) {
            return null;
        }//from   w w  w .j av a 2 s  . c o  m

        return getFormat(simple).parse(stringDate);
    }

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

Related

  1. getTimeDate(String time)
  2. getTimes(String startTime, String endTime)
  3. replaceDateTime(String input)
  4. str2DateTime(String strDate)
  5. string2Date(String time)
  6. string2DateTimeByAutoZero(String stringDate)
  7. stringToCalendar(String stringTime)
  8. stringToCalendar(String timeStr)
  9. stringToTimeDate(String timeStr)