Skip to content

@FixedFormatNumber positiveSign/negativeSign not respected when exporting #32

@GoogleCodeExporter

Description

@GoogleCodeExporter
What steps will reproduce the problem?
1. Annotate getter method using the @FixedFormatNumber(sign=Sign.PREPEND, 
positiveSign='0') 

What is the expected output? What do you see instead?
You would expect the output from the formatter to use '0' as positive sign. 
0000100 for positive 100 and -000100 for -100 

What version of the product are you using? On what Java version?


Please provide any additional information below.
Sign.PREPEND should use FixedFormatNumberData.positive sign and not '+'. A 
propesed solution would be:


  PREPEND {
    public String apply(String value, FormatInstructions instructions) {
      String sign = StringUtils.substring(value, 0, 1);
      if ("-".equals(sign)) {
        value = StringUtils.substring(value, 1);
        sign = instructions.getFixedFormatNumberData().getNegativeSign().toString();
      } else {
        sign = instructions.getFixedFormatNumberData().getPositiveSign().toString();
      }
      String result = instructions.getAlignment().apply(value, instructions.getLength(), instructions.getPaddingChar());
      return sign + StringUtils.substring(result, 1);
    }

Original issue reported on code.google.com by [email protected] on 29 Mar 2012 at 11:56

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions