fork(1) download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.text.DateFormat;
  4. import java.text.ParseException;
  5. import java.text.SimpleDateFormat;
  6. import java.util.Date;
  7. import java.util.TimeZone;
  8.  
  9. /* Name of the class has to be "Main" only if the class is public. */
  10. class Ideone
  11. {
  12. public static void main (String[] args) throws java.lang.Exception
  13. {
  14. String inputDate = "Fri, 27-Sep-2013 08:29:59 GMT";
  15. DateFormat format = new SimpleDateFormat ("EEE, dd-MMM-yyyy hh:mm:ss ZZZ");
  16. format.setTimeZone (TimeZone.getTimeZone ("GMT"));
  17. Date d = null;
  18. try {
  19. d = format.parse(inputDate);
  20. } catch (ParseException e) {
  21. e.printStackTrace();
  22. }
  23. System.out.println(d);
  24. }
  25. }
Success #stdin #stdout 0.1s 381056KB
stdin
Standard input is empty
stdout
Fri Sep 27 08:29:59 GMT 2013