Uploaded image for project: 'Commons Lang'
  1. Commons Lang
  2. LANG-1255

need a version of DateUtils.toCalendar that preserves or sets TimeZone

Attach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 3.4
    • Fix Version/s: 3.5
    • Component/s: lang.time.*
    • Labels:
      None

      Description

      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:

          public static Calendar toCalendar(final Date date, final TimeZone tz) {
              final Calendar c = Calendar.getInstance(tz);
              c.setTime(date);
              return c;
          }
      

        Attachments

          Activity

            People

            • Assignee:
              britter Benedikt Ritter
              Reporter:
              mcalmus Mike Calmus

              Dates

              • Created:
                Updated:
                Resolved:

                Issue deployment