{"action":"created","comment":{"url":"https://api.github.com/repos/jenkinsci/docker-workflow-plugin/pulls/comments/34412245","id":34412245,"diff_hunk":"@@ -183,12 +198,16 @@ public void rm(@Nonnull EnvVars launchEnv, @Nonnull String containerId) throws I\n         if (createdString == null) {\n             return null;\n         }\n-        try {\n-            // TODO Currently truncating. Find out how to specify last part for parsing (TZ etc)\n-            return new SimpleDateFormat(DOCKER_DATE_TIME_FORMAT).parse(createdString.substring(0, DOCKER_DATE_TIME_FORMAT.length() - 2));\n-        } catch (ParseException e) {\n-            throw new IOException(String.format(\"Error parsing created date '%s' for object '%s'.\", createdString, objectId), e);\n+        IOException problem = null;\n+        for (String fmt : DOCKER_DATE_TIME_FORMAT) {\n+            try {\n+                // TODO Currently truncating. Find out how to specify last part for parsing (TZ etc)\n+                return new SimpleDateFormat(fmt).parse(createdString.substring(0, fmt.replace(\"'\",\"\").length()));\n+            } catch (ParseException e) {\n+                problem = new IOException(String.format(\"Error parsing created date '%s' for object '%s'.\", createdString, objectId), e);","path":"src/main/java/org/jenkinsci/plugins/docker/workflow/client/DockerClient.java","position":57,"original_position":57,"commit_id":"f3286731c1db7a6af74590001e5e8022afb852d3","original_commit_id":"f3286731c1db7a6af74590001e5e8022afb852d3","user":{"login":"oleg-nenashev","id":3000480,"avatar_url":"https://avatars.githubusercontent.com/u/3000480?v=3","gravatar_id":"","url":"https://api.github.com/users/oleg-nenashev","html_url":"https://github.com/oleg-nenashev","followers_url":"https://api.github.com/users/oleg-nenashev/followers","following_url":"https://api.github.com/users/oleg-nenashev/following{/other_user}","gists_url":"https://api.github.com/users/oleg-nenashev/gists{/gist_id}","starred_url":"https://api.github.com/users/oleg-nenashev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/oleg-nenashev/subscriptions","organizations_url":"https://api.github.com/users/oleg-nenashev/orgs","repos_url":"https://api.github.com/users/oleg-nenashev/repos","events_url":"https://api.github.com/users/oleg-nenashev/events{/privacy}","received_events_url":"https://api.github.com/users/oleg-nenashev/received_events","type":"User","site_admin":false},"body":"This method will throw the problem only for the last time format","created_at":"2015-07-11T12:20:51Z","updated_at":"2015-07-11T12:20:51Z","html_url":"https://github.com/jenkinsci/docker-workflow-plugin/pull/15#discussion_r34412245","pull_request_url":"https://api.github.com/repos/jenkinsci/docker-workflow-plugin/pulls/15","_links":{"self":{"href":"https://api.github.com/repos/jenkinsci/docker-workflow-plugin/pulls/comments/34412245"},"html":{"href":"https://github.com/jenkinsci/docker-workflow-plugin/pull/15#discussion_r34412245"},"pull_request":{"href":"https://api.github.com/repos/jenkinsci/docker-workflow-plugin/pulls/15"}}},"pull_request":{"url":"https://api.github.com/repos/jenkinsci/docker-workflow-plugin/pulls/15","id":39738302,"html_url":"https://github.com/jenkinsci/docker-workflow-plugin/pull/15","diff_url":"https://github.com/jenkinsci/docker-workflow-plugin/pull/15.diff","patch_url":"https://github.com/jenkinsci/docker-workflow-plugin/pull/15.patch","issue_url":"https://api.github.com/repos/jenkinsci/docker-workflow-plugin/issues/15","number":15,"state":"open","locked":false,"title":"Handle the date format that my docker returns","user":{"login":"kohsuke","id":50003,"avatar_url":"https://avatars.githubusercontent.com/u/50003?v=3","gravatar_id":"","url":"https://api.github.com/users/kohsuke","html_url":"https://github.com/kohsuke","followers_url":"https://api.github.com/users/kohsuke/followers","following_url":"https://api.github.com/users/kohsuke/following{/other_user}","gists_url":"https://api.github.com/users/kohsuke/gists{/gist_id}","starred_url":"https://api.github.com/users/kohsuke/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kohsuke/subscriptions","organizations_url":"https://api.github.com/users/kohsuke/orgs","repos_url":"https://api.github.com/users/kohsuke/repos","events_url":"https://api.github.com/users/kohsuke/events{/privacy}","received_events_url":"https://api.github.com/users/kohsuke/received_events","type":"User","site_admin":false},"body":"I found that my docker daemon returns a string format that appears to be different from what Tom gets.\r\n\r\n```\r\nCaused by: java.text.ParseException: Unparseable date: \"2015-07-09 04:05:32\"\r\n \tat java.text.DateFormat.parse(DateFormat.java:366)\r\n \tat org.jenkinsci.plugins.docker.workflow.client.DockerClient.getCreatedDate(DockerClient.java:167)\r\n \tat org.jenkinsci.plugins.docker.workflow.client.DockerClient.getContainerRecord(DockerClient.java:263)\r\n \tat org.jenkinsci.plugins.docker.workflow.WithContainerStep$Execution.start(WithContainerStep.java:138)\r\n \tat org.jenkinsci.plugins.workflow.cps.DSL.invokeMethod(DSL.java:136)\r\n \tat org.jenkinsci.plugins.workflow.cps.CpsScript.invokeMethod(CpsScript.java:98)\r\n \tat groovy.lang.GroovyObject$invokeMethod.call(Unknown Source)\r\n \tat org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:42)\r\n \tat org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)\r\n \tat org.kohsuke.groovy.sandbox.impl.Checker$1.call(Checker.java:105)\r\n \tat org.kohsuke.groovy.sandbox.GroovyInterceptor.onMethodCall(GroovyInterceptor.java:21)\r\n \tat org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onMethodCall(SandboxInterceptor.java:75)\r\n \tat org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onMethodCall(SandboxInterceptor.java:60)\r\n \tat org.kohsuke.groovy.sandbox.impl.Checker$1.call(Checker.java:103)\r\n \tat org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:100)\r\n \tat com.cloudbees.groovy.cps.sandbox.SandboxInvoker.methodCall(SandboxInvoker.java:15)\r\n \t... 29 more\r\n```\r\nSo I've improved the code to handle both patterns.\r\n\r\nGiven that there is some variety in the date format, I think it is unwise to expose the format string.\r\nIt'd be much better off to expose a function that parse the string into a date object. Fortunately, no\r\none appears to be using this field, so this change looks OK compatibility wise.","created_at":"2015-07-11T02:26:28Z","updated_at":"2015-07-11T12:20:51Z","closed_at":null,"merged_at":null,"merge_commit_sha":"4436976797917603c2f72f4f535d6f63e99fbffe","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/jenkinsci/docker-workflow-plugin/pulls/15/commits","review_comments_url":"https://api.github.com/repos/jenkinsci/docker-workflow-plugin/pulls/15/comments","review_comment_url":"https://api.github.com/repos/jenkinsci/docker-workflow-plugin/pulls/comments{/number}","comments_url":"https://api.github.com/repos/jenkinsci/docker-workflow-plugin/issues/15/comments","statuses_url":"https://api.github.com/repos/jenkinsci/docker-workflow-plugin/statuses/f3286731c1db7a6af74590001e5e8022afb852d3","head":{"label":"jenkinsci:dateformat","ref":"dateformat","sha":"f3286731c1db7a6af74590001e5e8022afb852d3","user":{"login":"jenkinsci","id":107424,"avatar_url":"https://avatars.githubusercontent.com/u/107424?v=3","gravatar_id":"","url":"https://api.github.com/users/jenkinsci","html_url":"https://github.com/jenkinsci","followers_url":"https://api.github.com/users/jenkinsci/followers","following_url":"https://api.github.com/users/jenkinsci/following{/other_user}","gists_url":"https://api.github.com/users/jenkinsci/gists{/gist_id}","starred_url":"https://api.github.com/users/jenkinsci/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jenkinsci/subscriptions","organizations_url":"https://api.github.com/users/jenkinsci/orgs","repos_url":"https://api.github.com/users/jenkinsci/repos","events_url":"https://api.github.com/users/jenkinsci/events{/privacy}","received_events_url":"https://api.github.com/users/jenkinsci/received_events","type":"Organization","site_admin":false},"repo":{"id":36385785,"name":"docker-workflow-plugin","full_name":"jenkinsci/docker-workflow-plugin","owner":{"login":"jenkinsci","id":107424,"avatar_url":"https://avatars.githubusercontent.com/u/107424?v=3","gravatar_id":"","url":"https://api.github.com/users/jenkinsci","html_url":"https://github.com/jenkinsci","followers_url":"https://api.github.com/users/jenkinsci/followers","following_url":"https://api.github.com/users/jenkinsci/following{/other_user}","gists_url":"https://api.github.com/users/jenkinsci/gists{/gist_id}","starred_url":"https://api.github.com/users/jenkinsci/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jenkinsci/subscriptions","organizations_url":"https://api.github.com/users/jenkinsci/orgs","repos_url":"https://api.github.com/users/jenkinsci/repos","events_url":"https://api.github.com/users/jenkinsci/events{/privacy}","received_events_url":"https://api.github.com/users/jenkinsci/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/jenkinsci/docker-workflow-plugin","description":"","fork":false,"url":"https://api.github.com/repos/jenkinsci/docker-workflow-plugin","forks_url":"https://api.github.com/repos/jenkinsci/docker-workflow-plugin/forks","keys_url":"https://api.github.com/repos/jenkinsci/docker-workflow-plugin/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jenkinsci/docker-workflow-plugin/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jenkinsci/docker-workflow-plugin/teams","hooks_url":"https://api.github.com/repos/jenkinsci/docker-workflow-plugin/hooks","issue_events_url":"https://api.github.com/repos/jenkinsci/docker-workflow-plugin/issues/events{/number}","events_url":"https://api.github.com/repos/jenkinsci/docker-workflow-plugin/events","assignees_url":"https://api.github.com/repos/jenkinsci/docker-workflow-plugin/assignees{/user}","branches_url":"https://api.github.com/repos/jenkinsci/docker-workflow-plugin/branches{/branch}","tags_url":"https://api.github.com/repos/jenkinsci/docker-workflow-plugin/tags","blobs_url":"https://api.github.com/repos/jenkinsci/docker-workflow-plugin/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jenkinsci/docker-workflow-plugin/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jenkinsci/docker-workflow-plugin/git/refs{/sha}","trees_url":"https://api.github.com/repos/jenkinsci/docker-workflow-plugin/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jenkinsci/docker-workflow-plugin/statuses/{sha}","languages_url":"https://api.github.com/repos/jenkinsci/docker-workflow-plugin/languages","stargazers_url":"https://api.github.com/repos/jenkinsci/docker-workflow-plugin/stargazers","contributors_url":"https://api.github.com/repos/jenkinsci/docker-workflow-plugin/contributors","subscribers_url":"https://api.github.com/repos/jenkinsci/docker-workflow-plugin/subscribers","subscription_url":"https://api.github.com/repos/jenkinsci/docker-workflow-plugin/subscription","commits_url":"https://api.github.com/repos/jenkinsci/docker-workflow-plugin/commits{/sha}","git_commits_url":"https://api.github.com/repos/jenkinsci/docker-workflow-plugin/git/commits{/sha}","comments_url":"https://api.github.com/repos/jenkinsci/docker-workflow-plugin/comments{/number}","issue_comment_url":"https://api.github.com/repos/jenkinsci/docker-workflow-plugin/issues/comments{/number}","contents_url":"https://api.github.com/repos/jenkinsci/docker-workflow-plugin/contents/{+path}","compare_url":"https://api.github.com/repos/jenkinsci/docker-workflow-plugin/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jenkinsci/docker-workflow-plugin/merges","archive_url":"https://api.github.com/repos/jenkinsci/docker-workflow-plugin/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jenkinsci/docker-workflow-plugin/downloads","issues_url":"https://api.github.com/repos/jenkinsci/docker-workflow-plugin/issues{/number}","pulls_url":"https://api.github.com/repos/jenkinsci/docker-workflow-plugin/pulls{/number}","milestones_url":"https://api.github.com/repos/jenkinsci/docker-workflow-plugin/milestones{/number}","notifications_url":"https://api.github.com/repos/jenkinsci/docker-workflow-plugin/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jenkinsci/docker-workflow-plugin/labels{/name}","releases_url":"https://api.github.com/repos/jenkinsci/docker-workflow-plugin/releases{/id}","created_at":"2015-05-27T18:02:51Z","updated_at":"2015-07-08T21:30:57Z","pushed_at":"2015-07-11T02:26:29Z","git_url":"git://github.com/jenkinsci/docker-workflow-plugin.git","ssh_url":"git@github.com:jenkinsci/docker-workflow-plugin.git","clone_url":"https://github.com/jenkinsci/docker-workflow-plugin.git","svn_url":"https://github.com/jenkinsci/docker-workflow-plugin","homepage":"","size":414,"stargazers_count":6,"watchers_count":6,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":6,"mirror_url":null,"open_issues_count":4,"forks":6,"open_issues":4,"watchers":6,"default_branch":"master"}},"base":{"label":"jenkinsci:master","ref":"master","sha":"c81af8632223c625135b930bc5dd4a0714774a19","user":{"login":"jenkinsci","id":107424,"avatar_url":"https://avatars.githubusercontent.com/u/107424?v=3","gravatar_id":"","url":"https://api.github.com/users/jenkinsci","html_url":"https://github.com/jenkinsci","followers_url":"https://api.github.com/users/jenkinsci/followers","following_url":"https://api.github.com/users/jenkinsci/following{/other_user}","gists_url":"https://api.github.com/users/jenkinsci/gists{/gist_id}","starred_url":"https://api.github.com/users/jenkinsci/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jenkinsci/subscriptions","organizations_url":"https://api.github.com/users/jenkinsci/orgs","repos_url":"https://api.github.com/users/jenkinsci/repos","events_url":"https://api.github.com/users/jenkinsci/events{/privacy}","received_events_url":"https://api.github.com/users/jenkinsci/received_events","type":"Organization","site_admin":false},"repo":{"id":36385785,"name":"docker-workflow-plugin","full_name":"jenkinsci/docker-workflow-plugin","owner":{"login":"jenkinsci","id":107424,"avatar_url":"https://avatars.githubusercontent.com/u/107424?v=3","gravatar_id":"","url":"https://api.github.com/users/jenkinsci","html_url":"https://github.com/jenkinsci","followers_url":"https://api.github.com/users/jenkinsci/followers","following_url":"https://api.github.com/users/jenkinsci/following{/other_user}","gists_url":"https://api.github.com/users/jenkinsci/gists{/gist_id}","starred_url":"https://api.github.com/users/jenkinsci/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jenkinsci/subscriptions","organizations_url":"https://api.github.com/users/jenkinsci/orgs","repos_url":"https://api.github.com/users/jenkinsci/repos","events_url":"https://api.github.com/users/jenkinsci/events{/privacy}","received_events_url":"https://api.github.com/users/jenkinsci/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/jenkinsci/docker-workflow-plugin","description":"","fork":false,"url":"https://api.github.com/repos/jenkinsci/docker-workflow-plugin","forks_url":"https://api.github.com/repos/jenkinsci/docker-workflow-plugin/forks","keys_url":"https://api.github.com/repos/jenkinsci/docker-workflow-plugin/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jenkinsci/docker-workflow-plugin/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jenkinsci/docker-workflow-plugin/teams","hooks_url":"https://api.github.com/repos/jenkinsci/docker-workflow-plugin/hooks","issue_events_url":"https://api.github.com/repos/jenkinsci/docker-workflow-plugin/issues/events{/number}","events_url":"https://api.github.com/repos/jenkinsci/docker-workflow-plugin/events","assignees_url":"https://api.github.com/repos/jenkinsci/docker-workflow-plugin/assignees{/user}","branches_url":"https://api.github.com/repos/jenkinsci/docker-workflow-plugin/branches{/branch}","tags_url":"https://api.github.com/repos/jenkinsci/docker-workflow-plugin/tags","blobs_url":"https://api.github.com/repos/jenkinsci/docker-workflow-plugin/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jenkinsci/docker-workflow-plugin/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jenkinsci/docker-workflow-plugin/git/refs{/sha}","trees_url":"https://api.github.com/repos/jenkinsci/docker-workflow-plugin/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jenkinsci/docker-workflow-plugin/statuses/{sha}","languages_url":"https://api.github.com/repos/jenkinsci/docker-workflow-plugin/languages","stargazers_url":"https://api.github.com/repos/jenkinsci/docker-workflow-plugin/stargazers","contributors_url":"https://api.github.com/repos/jenkinsci/docker-workflow-plugin/contributors","subscribers_url":"https://api.github.com/repos/jenkinsci/docker-workflow-plugin/subscribers","subscription_url":"https://api.github.com/repos/jenkinsci/docker-workflow-plugin/subscription","commits_url":"https://api.github.com/repos/jenkinsci/docker-workflow-plugin/commits{/sha}","git_commits_url":"https://api.github.com/repos/jenkinsci/docker-workflow-plugin/git/commits{/sha}","comments_url":"https://api.github.com/repos/jenkinsci/docker-workflow-plugin/comments{/number}","issue_comment_url":"https://api.github.com/repos/jenkinsci/docker-workflow-plugin/issues/comments{/number}","contents_url":"https://api.github.com/repos/jenkinsci/docker-workflow-plugin/contents/{+path}","compare_url":"https://api.github.com/repos/jenkinsci/docker-workflow-plugin/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jenkinsci/docker-workflow-plugin/merges","archive_url":"https://api.github.com/repos/jenkinsci/docker-workflow-plugin/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jenkinsci/docker-workflow-plugin/downloads","issues_url":"https://api.github.com/repos/jenkinsci/docker-workflow-plugin/issues{/number}","pulls_url":"https://api.github.com/repos/jenkinsci/docker-workflow-plugin/pulls{/number}","milestones_url":"https://api.github.com/repos/jenkinsci/docker-workflow-plugin/milestones{/number}","notifications_url":"https://api.github.com/repos/jenkinsci/docker-workflow-plugin/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jenkinsci/docker-workflow-plugin/labels{/name}","releases_url":"https://api.github.com/repos/jenkinsci/docker-workflow-plugin/releases{/id}","created_at":"2015-05-27T18:02:51Z","updated_at":"2015-07-08T21:30:57Z","pushed_at":"2015-07-11T02:26:29Z","git_url":"git://github.com/jenkinsci/docker-workflow-plugin.git","ssh_url":"git@github.com:jenkinsci/docker-workflow-plugin.git","clone_url":"https://github.com/jenkinsci/docker-workflow-plugin.git","svn_url":"https://github.com/jenkinsci/docker-workflow-plugin","homepage":"","size":414,"stargazers_count":6,"watchers_count":6,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":6,"mirror_url":null,"open_issues_count":4,"forks":6,"open_issues":4,"watchers":6,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/jenkinsci/docker-workflow-plugin/pulls/15"},"html":{"href":"https://github.com/jenkinsci/docker-workflow-plugin/pull/15"},"issue":{"href":"https://api.github.com/repos/jenkinsci/docker-workflow-plugin/issues/15"},"comments":{"href":"https://api.github.com/repos/jenkinsci/docker-workflow-plugin/issues/15/comments"},"review_comments":{"href":"https://api.github.com/repos/jenkinsci/docker-workflow-plugin/pulls/15/comments"},"review_comment":{"href":"https://api.github.com/repos/jenkinsci/docker-workflow-plugin/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/jenkinsci/docker-workflow-plugin/pulls/15/commits"},"statuses":{"href":"https://api.github.com/repos/jenkinsci/docker-workflow-plugin/statuses/f3286731c1db7a6af74590001e5e8022afb852d3"}}}}