fork(1) download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.text.*;
  6. import java.io.*;
  7.  
  8. /* Name of the class has to be "Main" only if the class is public. */
  9. class Ideone
  10. {
  11. public static void main(String[] args) {
  12. SimpleDateFormat formatter = new SimpleDateFormat("dd MMMM yyyy - HH:mm a");
  13. String dateInString = "23 January 2017 - 02:50 pm";
  14.  
  15. try {
  16.  
  17. Date date = formatter.parse(dateInString);
  18. System.out.println(date);
  19. System.out.println(formatter.format(date));
  20.  
  21. } catch (ParseException e) {
  22. e.printStackTrace(System.out);
  23. }
  24.  
  25. }
  26. }
Success #stdin #stdout 0.06s 712192KB
stdin
Standard input is empty
stdout
Mon Jan 23 02:50:00 GMT 2017
23 January 2017 - 02:50 AM