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

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

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 3.4
    • 3.5
    • lang.time.*
    • 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

        Issue Links

          Activity

            People

              britter Benedikt Ritter
              mcalmus Mike Calmus
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: