Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import java.sql.Timestamp;

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

public class Main {

    public static String changeStringToDate3(String str) {

        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        java.util.Date date6 = null;
        try {
            date6 = sdf.parse(str);
            java.sql.Date date7 = new java.sql.Date(date6.getTime());
            Timestamp stamp9 = new Timestamp(date7.getTime());
            return stamp9.toString();
        } catch (ParseException e) {
            e.printStackTrace();
            return "";
        }
    }
}