Commons Lang
  1. Commons Lang
  2. LANG-194

[lang] add generic add method to DateUtils

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.2
    • Component/s: None
    • Labels:
      None
    • Environment:

      Operating System: Windows XP
      Platform: PC

      Description

      There is no way to do Date arithmetic in one line in Java, unless you use
      deprecated methods. The following method initializes a Calendar object with a
      date and performs date arithmetic on it, and returns the result as a java.util.Date.

      public static Date add(Date date, int field, int amount)

      { Calendar c = new GregorianCalendar(); c.setTime(date); c.add(field, amount); return c.getTime(); }

        Activity

        David Bowers created issue -
        Hide
        Henri Yandell added a comment -

        Calendar.getInstance() rather than new GregorianCalendar.

        Show
        Henri Yandell added a comment - Calendar.getInstance() rather than new GregorianCalendar.
        Hide
        Stephen Colebourne added a comment -

        Implemented in svn 394553

        Show
        Stephen Colebourne added a comment - Implemented in svn 394553
        Henri Yandell made changes -
        Field Original Value New Value
        issue.field.bugzillaimportkey 33102 12341999
        Henri Yandell made changes -
        Project Commons [ 12310458 ] Commons Lang [ 12310481 ]
        Key COM-1847 LANG-194
        Component/s Lang [ 12311121 ]
        Fix Version/s 2.2 [ 12311686 ]
        Assignee Jakarta Commons Developers Mailing List [ commons-dev@jakarta.apache.org ]
        Affects Version/s unspecified [ 12311647 ]
        Henri Yandell made changes -
        Fix Version/s 2.2 [ 12311702 ]
        Henri Yandell made changes -
        Status Resolved [ 5 ] Closed [ 6 ]
        Hide
        Henri Yandell added a comment -

        Reopening then closing to deal with migration bug.

        Show
        Henri Yandell added a comment - Reopening then closing to deal with migration bug.
        Henri Yandell made changes -
        Status Closed [ 6 ] Reopened [ 4 ]
        Hide
        Henri Yandell added a comment -

        Reopening then closing to deal with migration bug.

        Show
        Henri Yandell added a comment - Reopening then closing to deal with migration bug.
        Henri Yandell made changes -
        Resolution Fixed [ 1 ]
        Status Reopened [ 4 ] Closed [ 6 ]
        Mark Thomas made changes -
        Workflow jira [ 12370904 ] Default workflow, editable Closed status [ 12602029 ]

          People

          • Assignee:
            Unassigned
            Reporter:
            David Bowers
          • Votes:
            1 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development