Here you can find the source of getDateInput(String prompt)
public static java.sql.Date getDateInput(String prompt) throws ParseException
//package com.java2s; //License from project: Open Source License import java.io.BufferedReader; import java.io.InputStreamReader; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static java.sql.Date getDateInput(String prompt) throws ParseException { String input = getStringInput(prompt); Date newDate = new SimpleDateFormat("yyyy-MM-dd").parse(input); java.sql.Date SQLDate = new java.sql.Date(newDate.getTime()); return SQLDate; }/*w w w.j av a2s.c o m*/ public static String getStringInput(String prompt) { BufferedReader input = new BufferedReader(new InputStreamReader(System.in)); System.out.println(prompt); System.out.flush(); try { return input.readLine(); } catch (Exception exception) { return "Error: " + exception.getMessage(); } } }