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

Add StopWatch#getTime with String Format Argument

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Minor
    • Resolution: Won't Fix
    • None
    • None
    • lang.time.*
    • None

    Description

      Add a version of the StopWatch#getTime method which takes a String to format the time in the desired format.

      StopWatch watch= StopWatch.createStarted();
      // sleep for 1 hour, 19 minutes, 45.554 seconds
      try {Thread.sleep(4785554);} catch (final InterruptedException ex) {}
      watch.stop();
      System.out.println(watch.getTime("HH:mm:ss.SSS");
      // prints: 1:19:45.554
      

      I have a patch ready, but I wasn't sure if this kind of thing should be a part of the getTime method or if toString should be overloaded to take a format argument. Either way seems okay to me. I put it on getTime, but if there are disagreements about that, I would be okay with putting it in toString instead.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              nmanley Nick Manley
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: