Weird parsing date string error in Android 2.0 emulator
- by kknight
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"