Java Date Parse convertStringToDateTimeNotException(String date)

Here you can find the source of convertStringToDateTimeNotException(String date)

Description

convert String To Date Time Not Exception

License

Open Source License

Declaration

public static Date convertStringToDateTimeNotException(String date) 

Method Source Code


//package com.java2s;
/*/*from w ww .  j a v a 2s . c o  m*/
 * Copyright (C) 2010 dungnv. All rights reserved.
 * VIETTEL PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 */

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

import java.util.Date;

public class Main {
    public static Date convertStringToDateTimeNotException(String date) {
        String pattern = "dd/MM/yyyy HH:mm:ss";
        try {
            return convertStringToTime(date, pattern);
        } catch (Exception e) {
            return null;
        }
    }

    /**
     *
     * @param date to convert
     * @param pattern in converting
     * @return date
     */
    public static Date convertStringToTime(String date, String pattern) throws Exception {
        SimpleDateFormat dateFormat = new SimpleDateFormat(pattern);
        try {
            return dateFormat.parse(date);

        } catch (ParseException e) {
            System.out.println("Date ParseException, string value:" + date);
            throw e;
        }
    }
}

Related

  1. convertStringToDate(String str_date)
  2. convertStringToDate(String strDate)
  3. convertStringToDate(String strDate, String parseFormat)
  4. convertStringToDate(String stringDate, String pattern)
  5. convertStringToDate(String value)
  6. convertStringToDateWithRFC1123(final String dateTime)
  7. convertStringToTime(String date, String pattern)
  8. convertStringToTime(String date, String pattern)
  9. convertStrToDate(String dateStr, String dateFormat)