Bug 342086 - [framework] use of three-letter time zone IDs should be deprecated
Summary: [framework] use of three-letter time zone IDs should be deprecated
Status: RESOLVED FIXED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Mylyn (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: 3.6   Edit
Assignee: Mike Wu CLA
QA Contact:
URL:
Whiteboard:
Keywords: noteworthy
Depends on:
Blocks:
 
Reported: 2011-04-06 18:16 EDT by Mike Wu CLA
Modified: 2011-06-06 12:13 EDT (History)
1 user (show)

See Also:


Attachments
change timezone format to RFC 822 for externalizer (1.53 KB, patch)
2011-04-18 13:06 EDT, Mike Wu CLA
no flags Details | Diff
patch and test case (3.47 KB, patch)
2011-05-04 19:31 EDT, Mike Wu CLA
steffen.pingel: iplog+
Details | Diff
updated patch (4.42 KB, patch)
2011-05-17 19:03 EDT, Steffen Pingel CLA
no flags Details | Diff
mylyn/context/zip (15.98 KB, application/octet-stream)
2011-05-17 19:03 EDT, Steffen Pingel CLA
no flags Details
mylyn/context/zip (19.38 KB, application/octet-stream)
2011-05-17 19:14 EDT, Steffen Pingel CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Mike Wu CLA 2011-04-06 18:16:35 EDT
The DATE_FORMAT in org.eclipse.mylyn.internal.tasks.core.externalization.DelegatingTaskExternalizer currently uses three-letter time zone ID, which may causes incorrect Date objects being set, as the same three-letter time zone ID is often used for multiple time zones.

For example, if creating a task in "China Standard Time", the date will be saved as in "CST" time zone.  But when it's being read and parsed, Java will recognize the date string as in "Central Standard Time".

Using RFC 822 time zone format instead could be considered (http://download.oracle.com/javase/6/docs/api/java/text/SimpleDateFormat.html#rfc822timezone).
Comment 1 Steffen Pingel CLA 2011-04-13 17:07:34 EDT
Thanks for pointing that out. We should fix this. Mike, are you interested in providing a patch and test case to fix this?
Comment 2 Mike Wu CLA 2011-04-13 17:13:49 EDT
Sure!  (I don't have the permission to change assignee field nor the status though...)
Comment 3 Steffen Pingel CLA 2011-04-13 17:19:41 EDT
Great to hear. I have assigned the task to you.
Comment 4 Mike Wu CLA 2011-04-18 13:06:13 EDT
Created attachment 193500 [details]
change timezone format to RFC 822 for externalizer

Sorry Steffen, I've tried but still not sure how to write a test case to simulate the timezone change.  It'd be great if you could help me with that.  Thanks!
Comment 5 Steffen Pingel CLA 2011-05-04 18:57:43 EDT
I recommend TaskListExternalizationTest as a starting point. You can use TimeZone.setDefault(TimeZone.getTimeZone("TZID"))  to modify the time zone when running tests. 

Here is another related bug that you may also want to look at:

250865: scheduled dates should use UTC timestamps
https://bugs.eclipse.org/bugs/show_bug.cgi?id=250865

I haven't checked in detail so it might be a much larger scope and require significantly more effort and should probably be done separately since the change proposed for this bug makes sense independently.
Comment 6 Mike Wu CLA 2011-05-04 19:31:39 EDT
Created attachment 194783 [details]
patch and test case

Thanks Steffen for the tip!  Provided a test case that would fail without the patch and pass with the patch.
Comment 7 Steffen Pingel CLA 2011-05-17 19:03:54 EDT
Created attachment 195916 [details]
updated patch
Comment 8 Steffen Pingel CLA 2011-05-17 19:03:56 EDT
Created attachment 195917 [details]
mylyn/context/zip
Comment 9 Steffen Pingel CLA 2011-05-17 19:14:39 EDT
Thanks for the patch and test case Mike. I have modified the contribution to ensure that it is still possible to read older task lists that use the three letter format.
Comment 10 Steffen Pingel CLA 2011-05-17 19:14:41 EDT
Created attachment 195922 [details]
mylyn/context/zip
Comment 11 Mike Wu CLA 2011-05-17 19:32:34 EDT
Thanks for reviewing the patch, Steffen!  

Per http://download.oracle.com/javase/6/docs/api/java/text/SimpleDateFormat.html#timezone , the RFC 822 also accepts general time zone format for parsing, so I'm wondering if there is another reason why general time zone format is preferred when reading Date's?  Thanks!
Comment 12 Steffen Pingel CLA 2011-05-17 19:46:09 EDT
Thanks for pointing that out. I missed that comment in the JavaDoc. In that case my modification was unnecessary.
Comment 13 Mike Wu CLA 2011-05-17 19:51:00 EDT
You are welcome.  Glad I could help!  :)