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

[lang] add generic add method to DateUtils

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • None
    • 2.2
    • None
    • None
    • Operating System: Windows XP
      Platform: PC

    • 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

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

            Dates

              Created:
              Updated:
              Resolved: