Weird parsing date string error in Android 2.0 emulator

Posted by kknight on Stack Overflow See other posts from Stack Overflow or by kknight
Published on 2010-05-17T21:43:49Z Indexed on 2010/05/17 21:50 UTC
Read the original article Hit count: 207

Filed under:
|

I have a simple test code for testing SimpleDateFormat. This code works well on Eclipse and Android 1.5 emulator, but it failed at Android 2.0 emulator. Does anyone know why? Thanks.

public class TemplateActivity extends Activity {
   /** Called when the activity is first created. */
   @Override
   public void onCreate(Bundle savedInstanceState) {
       super.onCreate(savedInstanceState);
       TextView tv = new TextView(this);
       tv.setText(R.string.hello);
       setContentView(tv);

       SimpleDateFormat format =
           new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz");

       String dateStr = "Mon, 17 May 2010 01:45:41 GMT"; 

       try {
           Date parsed = format.parse(dateStr);
           Log.v("Test", parsed.toString());
       } catch (ParseException pe) {
           Log.v("Test", "ERROR: Cannot parse \"" + dateStr + "\"");
       }

   }
}

Log message:

V/Test(  400): ERROR: Cannot parse "Mon, 17 May 2010 01:45:41 GMT"

© Stack Overflow or respective owner

Related posts about android

Related posts about java