fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.sql.Timestamp;
  4. import java.text.SimpleDateFormat;
  5. import java.util.Date;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. String endDate = "Dec 31 2017 12:00AM";
  13. SimpleDateFormat dateFormat = new SimpleDateFormat("MMM dd yyyy hh:mmaa");
  14. Date parsedDate = dateFormat.parse(endDate);
  15. Timestamp timestamp = new Timestamp(parsedDate.getTime());
  16. System.out.println(endDate);
  17. System.out.println(timestamp);
  18. }
  19. }
Success #stdin #stdout 0.09s 2184192KB
stdin
Standard input is empty
stdout
Dec 31 2017 12:00AM
2017-12-31 00:00:00.0