Java Date Parse DateFromStringFormat(final String date, final String format)

Here you can find the source of DateFromStringFormat(final String date, final String format)

Description

Date From String Format

License

Open Source License

Declaration

public static Date DateFromStringFormat(final String date, final String format)
            throws NullPointerException, ParseException 

Method Source Code

//package com.java2s;
/*//  w  w  w. jav a2s.  c  o  m
 * Copyright (c) 2015. Sandata Technologies, LLC
 * 26 Harbor Park Drive, Port Washington, NY 11050, 800-544-7263
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of Sandata Technologies, LLC
 * ("Confidential Information"). You shall not disclose such Confidential Information and shall
 * use it only in accordance with the terms of the license agreement you entered into with
 * Sandata.
 */

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

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

public class Main {
    public static Date DateFromStringFormat(final String date, final String format)
            throws NullPointerException, ParseException {

        if (date == null) {
            throw new NullPointerException("DateUtil: DateFromStringFormat: date == null");
        }

        if (format == null) {
            throw new NullPointerException("DateUtil: DateFromStringFormat: format == null");
        }

        DateFormat dateFormat = new SimpleDateFormat(format, Locale.ENGLISH);

        return dateFormat.parse(date);
    }
}

Related

  1. dateFromString(String date, String pattern)
  2. dateFromString(String dateString)
  3. dateFromString(String dateString)
  4. dateFromString(String s)
  5. dateFromString(String value)
  6. dateFromW3CDTF(String date)
  7. dateParse(String date)
  8. dateParse(String date2BeParsed)
  9. dateParseFromMyJsFormat(String jsDate)