Java SQL Date Parse getSQLDate(String dateString)

Here you can find the source of getSQLDate(String dateString)

Description

get SQL Date

License

Open Source License

Declaration

public static java.sql.Date getSQLDate(String dateString) 

Method Source Code

//package com.java2s;
/**/*from w  w  w  . j  a v a2s . c  om*/
 * Created on Jul 2, 2005
 *
 *
 * Copyright 2005 by Arysys Technologies (P) Ltd.,
 * #3,Shop line,
 * Sasmira Marg,
 * Worli,Mumbai 400 025
 * India
 * 
 * All rights reserved.
 *
 * This software is the confidential and proprietary information
 * of Arysys Technologies (P) Ltd. ("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 Arysys Technologies (P) Ltd.
 * 
 */

import java.text.SimpleDateFormat;

import java.util.Date;

public class Main {
    public static java.sql.Date getSQLDate(String dateString) {
        Date date = new Date();
        try {
            SimpleDateFormat sdf = new SimpleDateFormat("dd-MMM-yyyy");
            date = sdf.parse(dateString);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return new java.sql.Date(date.getTime());
    }
}

Related

  1. getSqlDate(String dateString, String format)
  2. getSqlDate(String str)
  3. getSqlDateByShortStr(String dateStr)
  4. getSqlDateFromStr(DateFormat format, String s, boolean need_default)