Java Date Parse convertStringToTime(String date, String pattern)

Here you can find the source of convertStringToTime(String date, String pattern)

Description

convert String To Time

License

Open Source License

Declaration

public static Date convertStringToTime(String date, String pattern) throws ParseException 

Method Source Code

//package com.java2s;
/*/*from  w w w . j  a  v  a2 s. com*/
 * Copyright (C) 2010 Viettel Telecom. All rights reserved.
 * VIETTEL PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 */

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

import java.util.Date;
import java.util.Locale;

public class Main {
    public static Date convertStringToTime(String date, String pattern) throws ParseException {
        if (date == null || "".equals(date.trim())) {
            return null;
        }
        SimpleDateFormat dateFormat = new SimpleDateFormat(pattern, Locale.ENGLISH);
        return dateFormat.parse(date);

    }
}

Related

  1. convertStringToDate(String stringDate, String pattern)
  2. convertStringToDate(String value)
  3. convertStringToDateTimeNotException(String date)
  4. convertStringToDateWithRFC1123(final String dateTime)
  5. convertStringToTime(String date, String pattern)
  6. convertStrToDate(String dateStr, String dateFormat)
  7. convertStrToDate(String day)
  8. convertStrToDate(String s, String format)
  9. convertStrToDate(String source)