Hi, I noticed that the rounding mode for CsvNumber is HALF_EVEN.
I can't seem to find anyway to change the mode to something else, for instance HALF_UP.
Is it possible to do so or I need to create my own converter for this?
You will have to create a custom converter for this. This was a use case that was not considered in the original design and would be easier to create a converter than to modify CsvNumber, ConverterNumber, and AbstractMappingStrategy.
👍
1
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Actually, it's not hard at all, I think. I'm working on it. Quick question, though, since I have rarely had the pleasure of rounding numbers: are we talking about while reading or writing CSV files?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I think both of my questions might be irrelevant. I simply pass the rounding mode to DecimalFormat, and what it uses that for isn't that important to me. I've written a test for writing BigDecimals to a CSV output to make certain the rounding mode arrives where it's supposed to be and is applied as advertised, and that test passes.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
You will have to create a custom converter for this. This was a use case that was not considered in the original design and would be easier to create a converter than to modify CsvNumber, ConverterNumber, and AbstractMappingStrategy.
Actually, it's not hard at all, I think. I'm working on it. Quick question, though, since I have rarely had the pleasure of rounding numbers: are we talking about while reading or writing CSV files?
And one more little question: we're only talkig about BigDecimal, right? I don't see RoundingMode being used anywhere else.
I think both of my questions might be irrelevant. I simply pass the rounding mode to DecimalFormat, and what it uses that for isn't that important to me. I've written a test for writing BigDecimals to a CSV output to make certain the rounding mode arrives where it's supposed to be and is applied as advertised, and that test passes.
This is implemented and will go out with the next release.
Version 5.9 has been released with this feature.