[ 
https://issues.apache.org/jira/browse/LANG-763?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13815321#comment-13815321
 ] 

Attila Király edited comment on LANG-763 at 11/6/13 9:37 PM:
-------------------------------------------------------------

Sorry for that I have only checked it with Java7.

I have now updated the pull request with a second commit to restore Java6 
compatibility.

I have used reflection instead of extending SimpleTimeZone. I have 
intentionally avoided using SimpleTimeZone in this task because with that the 
only way I could imagine to make this work would be:
- to create a SimpleTimeZone subclass which makes an instance immutable
- and an instance of it which behaves exactly the same as the UTC timezone 
returned by the JVM

I think the second point would be too "hacky" and hard to maintain thats why I 
went with a different approach:
- keep the UTC instance returned by the JVM, just wrap it in a delegating 
TimeZone that blocks mutable methods
So if the UTC instance behaviour changes the code will still work.

Please take a look.


was (Author: akiraly):
Sorry for that I have only checked it with Java7.

I have now updated the pull request with a second commit to restore Java6 
compatibility.

I have used reflection instead of extending SimpleTimeZone. I have 
intentionally avoided using SimpleTimeZone in this task because with that the 
only way I could imagine to make this work would be:
- to create a SimpleTimeZone subclass which makes an instance immutable
- and an instance of it which behaves exactly the same as the UTC timezone 
returned by the JVM

I think the second point would be too "hacky" and hard to maintain thats why I 
went with a different approach:
- keep the UTC instance returned by JVM just wrap it in a delegating TimeZone 
that blocks mutability methods
So if the UTC instance behaviour changes the code will still work.

Please take a look.

> Reintroduce DateUtils.UTC_TIME_ZONE constant
> --------------------------------------------
>
>                 Key: LANG-763
>                 URL: https://issues.apache.org/jira/browse/LANG-763
>             Project: Commons Lang
>          Issue Type: New Feature
>          Components: lang.time.*
>    Affects Versions: 3.0.1
>            Reporter: Attila Király
>            Priority: Minor
>             Fix For: Review Patch
>
>
> In LANG-691 DateUtils.UTC_TIME_ZONE was removed because TimeZone-s are 
> mutable. However it was a handy constant. So it would be nice if it could be 
> reintroduced in an immutable way. For example:
> - by creating a new static method DateUtils.utcTimeZone() {return 
> TimeZone.getTimeZone("GMT");}
> - or by creating an immutable timezone type (subclassing maybe SimpleTimeZone)



--
This message was sent by Atlassian JIRA
(v6.1#6144)

Reply via email to