Prasanna Raman wrote:..although I am still thinking if I should do the right thing and make it a double...
Stephan van Hulst wrote:you may want to stick with what you have until you manage to convince your project lead that it's okay to replace strings with better types as you go.
Prasanna Raman wrote:
Stephan van Hulst wrote:you may want to stick with what you have until you manage to convince your project lead that it's okay to replace strings with better types as you go.
By this you mean, until I manage to convince them to change it in all places consistently?
Or a long, which can store over $9×10¹⁷ if you use cents. There are new currency classes coming out with Java9, but I haven't managed to see how they work yet. So I don't know whether they will help you.Stephan van Hulst wrote:. . . I would use a BigInteger to store money in cents. . . .
Stephan van Hulst wrote:Probably not, because the front-end doesn't know what a BigDecimal is.
Paul Clapham wrote:Of course, everything sent from the front end is a string. HTTP requests are just text -- at least, they are bytes, but you can't expect to get (say) 8 bytes which represent a Java long variable directly. You're going to get some kind of text and you're going to have to convert some of that text into a numeric type.
All things are lawful, but not all things are profitable.
almost all of the income related fields in our application are declared as "String"
...we are an application that is a pass through - we receive a String from the UI and then pass it onto another application for storing in the database.
All things are lawful, but not all things are profitable.
Prasanna Raman wrote:Hello Paul,
Yes, all the fields are declared as String, and are converted to int or double using Integer.parseInt() before passing the fields on to the other application.
Prasanna Raman wrote:Yes, all the fields are declared as String, and are converted to int or double using Integer.parseInt() before passing the fields on to the other application.
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Winston Gutkowski wrote:
1. You have a String that contains a numeric amount with possible currency symbols involved.
Dave Tolls wrote:
Winston Gutkowski wrote:
1. You have a String that contains a numeric amount with possible currency symbols involved.
I would question a UI that sent currency symbols to the backend as part of an amount string.
Dave Tolls wrote:I would question a UI that sent currency symbols to the backend as part of an amount string.
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
What do you have in that there bucket? It wouldn't be a tiny ad by any chance ...
Smokeless wood heat with a rocket mass heater
https://woodheat.net
|