[jira] [Commented] (LANG-1255) need a version of DateUtils.toCalendar that preserves or sets TimeZone
[ https://issues.apache.org/jira/browse/LANG-1255?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15540155#comment-15540155 ] ASF GitHub Bot commented on LANG-1255: -- Github user asfgit closed the pull request at: https://github.com/apache/commons-lang/pull/192 > need a version of DateUtils.toCalendar that preserves or sets TimeZone > -- > > Key: LANG-1255 > URL: https://issues.apache.org/jira/browse/LANG-1255 > Project: Commons Lang > Issue Type: Improvement > Components: lang.time.* >Affects Versions: 3.4 >Reporter: Mike Calmus > > DateUtils.toCalendar creates a Calendar using .getInstance(). This results in > a Calendar in the machine's timezone. The Date object passed in may not be in > that same timezone. Since the getTimezoneOffset method of Date is deprecated > a new version of toCalendar that accepts a TimeZone would be appropriate: > {code:java} > public static Calendar toCalendar(final Date date, final TimeZone tz) { > final Calendar c = Calendar.getInstance(tz); > c.setTime(date); > return c; > } > {code} -- This message was sent by Atlassian JIRA (v6.3.4#6332)
[jira] [Commented] (LANG-1255) need a version of DateUtils.toCalendar that preserves or sets TimeZone
[ https://issues.apache.org/jira/browse/LANG-1255?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15508762#comment-15508762 ] ASF GitHub Bot commented on LANG-1255: -- GitHub user kaiyuanw opened a pull request: https://github.com/apache/commons-lang/pull/192 Lang 1255: Add DateUtils.toCalendar(Date, TimeZone) and 3 unit tests Added new toCalendar method in DateUtils with 3 unit tests as proposed in LANG-1255. You can merge this pull request into a Git repository by running: $ git pull https://github.com/kaiyuanw/commons-lang lang-1255 Alternatively you can review and apply these changes as the patch at: https://github.com/apache/commons-lang/pull/192.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #192 commit 1eecfc948bf6f4cbb9a2481313ca7368ec653056 Author: Kaiyuan WangDate: 2016-09-21T04:58:36Z Add DateUtils.toCalendar(Date, TimeZone) commit ac5a216f767c6defa4da720c6ecb3baa05e30254 Author: Kaiyuan Wang Date: 2016-09-21T04:59:04Z Add unit tests for DateUtils.toCalendar(Date, TimeZone) > need a version of DateUtils.toCalendar that preserves or sets TimeZone > -- > > Key: LANG-1255 > URL: https://issues.apache.org/jira/browse/LANG-1255 > Project: Commons Lang > Issue Type: Improvement > Components: lang.time.* >Affects Versions: 3.4 >Reporter: Mike Calmus > > DateUtils.toCalendar creates a Calendar using .getInstance(). This results in > a Calendar in the machine's timezone. The Date object passed in may not be in > that same timezone. Since the getTimezoneOffset method of Date is deprecated > a new version of toCalendar that accepts a TimeZone would be appropriate: > {code:java} > public static Calendar toCalendar(final Date date, final TimeZone tz) { > final Calendar c = Calendar.getInstance(tz); > c.setTime(date); > return c; > } > {code} -- This message was sent by Atlassian JIRA (v6.3.4#6332)
[jira] [Commented] (LANG-1255) need a version of DateUtils.toCalendar that preserves or sets TimeZone
[ https://issues.apache.org/jira/browse/LANG-1255?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15408150#comment-15408150 ] Gary Gregory commented on LANG-1255: Please feel free to provide a patch with unit tests. > need a version of DateUtils.toCalendar that preserves or sets TimeZone > -- > > Key: LANG-1255 > URL: https://issues.apache.org/jira/browse/LANG-1255 > Project: Commons Lang > Issue Type: Improvement > Components: lang.time.* >Affects Versions: 3.4 >Reporter: Mike Calmus > > DateUtils.toCalendar creates a Calendar using .getInstance(). This results in > a Calendar in the machine's timezone. The Date object passed in may not be in > that same timezone. Since the getTimezoneOffset method of Date is deprecated > a new version of toCalendar that accepts a TimeZone would be appropriate: > {code:java} > public static Calendar toCalendar(final Date date, final TimeZone tz) { > final Calendar c = Calendar.getInstance(tz); > c.setTime(date); > return c; > } > {code} -- This message was sent by Atlassian JIRA (v6.3.4#6332)