tl;dr
Use modern java.time classes.
OffsetDateTime
.parse (
"Sun, 04 Dec 2011 18:40:22 GMT+0" ,
DateTimeFormatter
.ofPattern ( "EEE, dd MMM uuuu HH:mm:ss O" )
.withLocale ( Locale.of ( "en" , "US" ) )
)
.toString ( )
java.time in modern Java
Avoid the terribly-flawed legacy classes such as Calendar, Date, and SimpleDateFormat. Use only the java.time classes in Java 8+.
RFC 822 & 1123
Your input string "Sun, 04 Dec 2011 18:40:22 GMT+0" seems to be a screwy version of the outmoded standard format defined in RFC 822 & RFC 1123. Java comes with a predefined formatter RFC_1123_DATE_TIME for those standards, but your input varies a bit too much for that to work.
Tip: For storing and exchanging date-time values textually, use only ISO 8601 formats.
DateTimeFormatter
So we need to define our own pattern to match your input. Use DateTimeFormatter class.
DateTimeFormatter.ofPattern ( "EEE, dd MMM uuuu HH:mm:ss O" )
Locale
We need a Locale to specify the human language and cultural norms to be used in translating the name of the month and name of the day-of-week.
Locale locale = Locale.of ( "en" , "US" );
DateTimeFormatter f = DateTimeFormatter.ofPattern ( "EEE, dd MMM uuuu HH:mm:ss O" ).withLocale ( locale );
OffsetDateTime
Parse as a OffsetDateTime, to represent a moment as seen with an offset from the temporal meridian of UTC.
In this case the offset is zero hours-minutes-seconds from UTC. Shown below as Z, pronounced “Zulu”.
String input = "Sun, 04 Dec 2011 18:40:22 GMT+0";
OffsetDateTime odt = OffsetDateTime.parse ( input , f );
Result:
odt.toString() = 2011-12-04T18:40:22Z