Skip to content

Inconsistency in TimeZone parsing between Robo tests and Android runtime #1257

Description

@anothem

I'm not sure if this is a bug per-say, but since it would create a situation where your tests pass, but your code would fail, I think we should try and fix it if possible.

This code sample would run ok on Robo, but the code actually fails on a device.

@Test
public void testDateParse() throws ParseException { 
    String datetime = "Wed Sep 03 12:59:27 BST 2014";

    new SimpleDateFormat("EEE MMM dd HH:mm:ss z yyyy", Locale.ENGLISH)
        .parse(datetime);
} 

I've explained the problem in the SO answer below, but briefly the issue is that Android doesn't support 3-letter timezone abbreviations other than GMT and UTC, whereas the JVM does for compatibility reasons. So parsing BST works on the JVM, but fails on Android.
http://stackoverflow.com/questions/25668741/british-summer-time-bst-not-recognised-by-simpledateformat-timezone/25669688#25669688

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions