commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <>
Subject [jira] [Commented] (LANG-1255) need a version of DateUtils.toCalendar that preserves or sets TimeZone
Date Wed, 21 Sep 2016 05:03:20 GMT


ASF GitHub Bot commented on LANG-1255:

GitHub user kaiyuanw opened a pull request:

    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 lang-1255

Alternatively you can review and apply these changes as the patch at:

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 Wang <>
Date:   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:
>             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

View raw message