Announcement Announcement Module
Collapse
No announcement yet.
formatting decimal values in fixed length file output Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • formatting decimal values in fixed length file output

    I've been trying to find out how to format a decimal value into a fixed length file output such that leading zeroes are replaced with spaces. For example, given a double value of 21.5, I want the result to be a string that looks like this:
    " 21.50" (one leading space). Similarly, if the value is 1.5, I want the result to be " 1.50" (2 leading spaces)
    Have done some research and tried DecimalFormat from java.text, but haven't found a way to get the desired result. Any help would be much appreciated. Thanks

  • #2
    What version of Spring Batch are you using? This was something we recognized and fixed in 2.0.

    Comment


    • #3
      We are currently using 1.1.3.RELEASE-A and the decisions concerning what software/what version are not in my hands. I have to convince the project manager before a change can be made. What benefits would we see, other than this specific issue?

      Comment


      • #4
        The latest version of the docs contain a 'What's new in 2.0' section, but they haven't been pushed to the site yet. (mvn site in the docs directory will generate them for you if you like) Dave also wrote a blog post a couple of months ago highlighting the main themes:

        http://blog.springsource.com/2008/10...ature-rundown/

        It's not an exhaustive list, but its a pretty reasonable summary.

        Comment


        • #5
          Looking at the Spring Batch download area, it appears 2.0 is not a GA release, yet. How stable is it?

          Comment


          • #6
            I would say it's pretty stable. We plan to release the first release candidate on February 13th.

            Comment


            • #7
              FixedLengthLineAggregator has padding and alignment. It isn't as fully featured as the String formatter option in 2.0, but it does pad numbers with spaces. Didn't it work in your case? You can probably write your own LineAggregator quite easily as well with String.format().

              Comment


              • #8
                Thanks for your help. As I suspected, our team leader doesn't want to upgrade right now because too many code changes would be required and we're on a fairly tight deadline.

                Comment

                Working...
                X