Java String to Date toDate(String patten, String value)

Here you can find the source of toDate(String patten, String value)

Description

To date.

License

Open Source License

Parameter

Parameter Description
patten the patten
value the value

Return

the date

Declaration

public static Date toDate(String patten, String value) 

Method Source Code

//package com.java2s;
/**// w w w.  j  a  v  a2  s  .co  m
 * *********************************************************************
 * Copyright (c) 2015 InfoZen, Inc. All rights reserved. InfoZen
 * PROPRIETARY/CONFIDENTIAL. Usage is subject to license terms.
 * *********************************************************************
 */

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

import java.util.Date;

public class Main {
    /**
     * To date.
     *
     * @param patten
     *            the patten
     * @param value
     *            the value
     * @return the date
     */
    public static Date toDate(String patten, String value) {
        DateFormat formater = new SimpleDateFormat(patten);

        try {
            return formater.parse(value);
        } catch (ParseException e) {
            throw new IllegalArgumentException(e);
        }

    }
}

Related

  1. toDate(String dateToDatify)
  2. toDate(String dateValue, String format)
  3. toDate(String format, String str)
  4. toDate(String formatDate, String stringDate)
  5. toDate(String param)
  6. toDate(String pattern, String date)
  7. toDate(String pString, String pFormat)
  8. toDate(String s)
  9. toDate(String s)