MainClass.java Source code

Java tutorial

Introduction

Here is the source code for MainClass.java

Source

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

public class MainClass {

    public static void main(String[] args) throws ParseException {
        try {
            SimpleDateFormat formatter = new SimpleDateFormat("yyyy/MM/dd");
            String date = "2003/01/10";
            java.util.Date utilDate = formatter.parse(date);
            java.sql.Date sqlDate = new java.sql.Date(utilDate.getTime());
            System.out.println("date:" + date);
            System.out.println("sqlDate:" + sqlDate);
        } catch (ParseException e) {
            System.out.println(e.toString());
            e.printStackTrace();
        }

    }

}