Here you can find the source of getSqlDateByShortStr(String dateStr)
public static java.sql.Date getSqlDateByShortStr(String dateStr)
//package com.java2s; import java.sql.Timestamp; import java.text.DateFormat; import java.util.Calendar; public class Main { static final DateFormat YYYYMMDD_FORMAT = new java.text.SimpleDateFormat("yyyyMMdd"); public static java.sql.Date getSqlDateByShortStr(String dateStr) { java.sql.Date da = null;//from w w w. j a va 2 s .com try { da = new java.sql.Date(YYYYMMDD_FORMAT.parse(dateStr).getTime()); } catch (Exception e) { e.printStackTrace(); } return da; } public static String getTime() { Timestamp time = new Timestamp(Calendar.getInstance().getTime().getTime()); return time.toString(); } }