HttpURLConnection ifModifiedSince generates UTC time instead of GMT
<p>I have the following method:</p>

<pre><code>public void GetBackground(final int width, final int height, final Long ifModifiedSince,
        final GetBackgroundListener listener)
{
    new Thread(new Runnable()
    {
        public void run()
        {
            try {
                String urlString = serviceUri + "/DownloadBackground?width=" + width
                        + "&amp;height=" + height;
                URL url = new URL(urlString);
                HttpURLConnection connection = (HttpURLConnection)url.openConnection();
                if (ifModifiedSince != null) {
                    Log.d(TAG, "Background last modified: " + ifModifiedSince);
                    connection.setIfModifiedSince(ifModifiedSince);
                }
                InputStream stream = (InputStream)connection.getContent();
                if (connection.getResponseCode() == HttpURLConnection.HTTP_NOT_MODIFIED) {
                    listener.onNotModified();
                    Log.d(TAG, "Background not modified");
                } else {
                    Bitmap background = BitmapFactory.decodeStream(stream);
                    listener.onSuccess(background, connection.getLastModified());
                    Log.d(TAG, "New background");
                }
            } catch (Exception e) {
                listener.onError(e);
            }
        }
    }).start();
}
</code></pre>

<p>On Android 2.2 it generates the following package:</p>

<pre><code>GET /QurrentService.svc/DownloadBackground?width=480&amp;height=480 HTTP/1.1
if-modified-since: Thu, 13 Dec 2012 09:11:23 GMT
User-Agent: Dalvik/1.2.0 (Linux; U; Android 2.2; sdk Build/FRF91)
Host: qurrentfeed1.1.aliencms.nl
Connection: Keep-Alive
</code></pre>

<p>And on Android 4.1:</p>

<pre><code>GET /QurrentService.svc/DownloadBackground?width=800&amp;height=800 HTTP/1.1
User-Agent: Dalvik/1.6.0 (Linux; U; Android 4.1.2; sdk Build/MASTER)
Host: qurrentfeed1.1.aliencms.nl
Connection: Keep-Alive
Accept-Encoding: gzip
If-Modified-Since: Thu, 13 Dec 2012 09:11:23 UTC
</code></pre>

<p>I'm not sure whether it's allowed to send the If-modified-since date as a UTC time, but the server fails to parse the date.
Is there a way to force the HttpURLConnection to generate a GMT format? Or should I set the header manually like this?</p>

<pre><code>String ifModifiedSinceString = DateUtils.formatDate(new Date(ifModifiedSince), "EEE, d MMM yyyy HH:mm:ss 'GMT'");
connection.addRequestProperty("If-Modified-Since", ifModifiedSinceString);
</code></pre>
