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

[lang] add generic add method to DateUtils

    Details

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

      Operating System: Windows XP
      Platform: PC

    • Bugzilla Id:
      33102

      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(); }

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              vive_lafrique@yahoo.com David Bowers
            • Votes:
              1 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: