Here you can find the source of getDateOfShortStr(String dateStr)
public static java.sql.Date getDateOfShortStr(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 getDateOfShortStr(String dateStr) { java.sql.Date da = null;//from w ww . ja v a 2 s . c o m 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(); } }