Cookie parsing issue w/ date in Android
<p>In my app, I am persisting a CookieStore by writing it out to a file as a long String using SharedPreferences. When reading this String back in, I parse each cookie and its attributes (name, value, domain, path, version, expiry date) from the String using regexps. As I parse these attributes, I reconstruct a CookieStore by making a new BasicClientCookie object for each cookie that is parsed, then add each one to a new CookieStore. </p>

<p>My issue comes up when I am parsing the expiry date as follows:</p>

<pre><code>CookieStore cs = new CookieStore();
SimpleDateFormat sdf = new SimpleDateFormat( "EEE MMM d HH:mm:ss zzz yyyy" );
//name, value, domain, path, expiry, and version are cookie attribute strings that I have parsed
//for(each cookie)
BasicClientCookie bcc = new BasicClientCookie( name, value );
bcc.setDomain(domain);
bcc.setPath(path);
bcc.setVersion(version);
bcc.setExpiryDate( sdf.parse(expiry) );
cs.addCookie(bcc);
</code></pre>

<p>This works fine in OS 1.5: the SimpleDateFormat object is able to parse expiry dates with the following format: [expiry: Fri Apr 02 11:23:38 PDT 2010]</p>

<p>However, in OS 2.0 and above, the expiry dates are formatted differently: [expiry: Fri Apr 02 11:28:21 America/Los_Angeles 2010]</p>

<p>The timezone formatting differs in OS 2.0+ so the sdf.parse() method throws:
W/System.err(10134): java.text.ParseException: Unparseable date: Fri Apr 02 11:35:34 America/Los_Angeles 2010</p>

<p>Now according to <a href="http://developer.android.com/reference/java/text/SimpleDateFormat.html" rel="nofollow">this</a>, I can parse timezones like "America/Los_Angeles" using the "v" format specifier. So I try an sdf object with "EEE MMM d HH:mm:ss vvv yyyy" format string but it does not recognize the "v" format specifier.</p>

<p>E/AndroidRuntime(10194): java.lang.IllegalArgumentException: Unknown pattern character - 'v'
E/AndroidRuntime(10194):    at java.text.SimpleDateFormat.validateFormat(SimpleDateFormat.java:379)</p>

<p>I am building my project w/ the 1.5 SDK and my Java version is 1.6. I have not been able to find out why the "v" format specifier is not recognized. I am importing java.text.SimpleDateFormat. Is that the wrong one? Does anyone see a better approach to this?</p>
