Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-438

String objects could use left-pad and right-pad methods

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 1.0-beta-4
    • 1.0-beta-5
    • groovy-jdk
    • None
    • 1.0-beta-4, Mac OS X 10.3.3, Java 1.4.2

    Description

      When formatting output for scripts run from the command line and plain-text reports, it is useful to be able to pad a string to a given width so that columns can line up. Python and Ruby provide ljust() and rjust() methods on string objects for this: "3.4".rjust(8) creates an 8-character string with the text "3.4" right-aligned in it.

      The StringUtils class in commons-lang has padLeft() and padRight() methods – as well as center() – but it would be much nicer to have these directly accessible from string objects instead of using static members of an outside class.

      Attachments

        Activity

          People

            guillaume Guillaume Sauthier
            marshall Marshall McMullen
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: