How to convert complex date string to datetime java

I have the following line that I need to put in a date

Sat, May 21, 2011 21:31:35 GMT

So far I have been doing the following, but I'm not sure of the correct format to get this parsing. Any help would be appreciated!

SimpleDateFormat df = new SimpleDateFormat("dd/MM/yyyy");
Date date = df.parse("Sat, 21-May-2011 21:31:35 GMT");

Thank you in advance

+3
source share
1 answer

See the documentation for SimpleDateFormata format. You should have something like this.

SimpleDateFormat df = new SimpleDateFormat("EEE, dd-MMM-yyyy HH:mm:ss zzz");
+6
source

All Articles