Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import java.sql.Date;
import java.text.SimpleDateFormat;

public class Main {
    public static Date convertStringtoDate(String data) {

        if (data == null || data.equals(""))
            return null;

        Date date = null;
        try {
            SimpleDateFormat formato = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
            date = new java.sql.Date(formato.parse(data).getTime());
        } catch (java.text.ParseException e) {
            date = null;
        }
        return date;
    }
}