Add annotation for number formating.
Brought to you by:
aruckerjones,
sconway
Hi,
could you please add the possibility to provide a format for floating point numbers (Double)?
There is already an annotation for dates (@CsvDate). Maybe you could come up with another annotation?
Example:
@CsvBindByPosition(position = 6, locale = "de")
@CsvNumber("#0.00")
private Double value;
Currently I solved this by having my own Double-converter and added an annotation that takes the format and the locale as a parameter:
@CsvCustomBindByPosition(position = 6, converter = CsvCustomDoubleConverter.class)
@CsvNumberFormat(format = "#0.00000#####", locale = "de")
private Double value;
Would be great if you would consider to add this feature in a future release.
Cheers,
Patrick
Yes, I like this idea. I believe I will be implementing this for version 4.3.
Hello Patrick - In both Feature Request 94 and 95 you state you have your own solution. Please send us the code because it be the solution or the basis of our solution.
Thanks in advance.
Scott :)
P.S. Please include your unit tests <bg>.</bg>
Hi Scott,
please find my solution in the attachment. There are also unit tests for the custom converter.
I did not really test the method
convert(String value)in the class CsvCustomDoubleConverter in real life as I just export files and do not write into database.Hope this helps...
Patrick
I have implemented this feature and it will be released with version 4.2.
4.2 has been released.
Great! Just removed my solution from our project and replaced it with yours.
Thank you very much for your effort!